Skip to content

Commit

Permalink
Merge pull request #544 from Stremio/notifications_bucket_created_def…
Browse files Browse the repository at this point in the history
…ault

remove Default impl from Ctx
  • Loading branch information
elpiel authored Oct 22, 2023
2 parents 34a0a9b + ce3b956 commit 0859574
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/models/ctx/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::types::profile::{Auth, AuthKey, Profile};
use crate::types::resource::MetaItem;
use crate::types::streams::StreamsBucket;

#[cfg(test)]
use derivative::Derivative;
use enclose::enclose;
use futures::{future, FutureExt, TryFutureExt};
Expand All @@ -30,8 +31,9 @@ pub enum CtxStatus {
Ready,
}

#[derive(Derivative, Serialize, Deserialize, Clone, Debug)]
#[derivative(Default)]
#[derive(Serialize, Deserialize, Clone, Debug)]
#[cfg_attr(test, derive(Derivative))]
#[cfg_attr(test, derivative(Default))]
pub struct Ctx {
pub profile: Profile,
// TODO SubtitlesBucket
Expand All @@ -42,7 +44,7 @@ pub struct Ctx {
#[serde(skip)]
pub streams: StreamsBucket,
#[serde(skip)]
#[derivative(Default(value = "CtxStatus::Ready"))]
#[cfg_attr(test, derivative(Default(value = "CtxStatus::Ready")))]
pub status: CtxStatus,
#[serde(skip)]
/// Used only for loading the Descriptor and then the descriptor will be discarded
Expand All @@ -63,7 +65,9 @@ impl Ctx {
library,
streams,
notifications,
..Self::default()
trakt_addon: None,
notification_catalogs: vec![],
status: CtxStatus::Ready,
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/types/notifications/notifications_bucket.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::collections::{hash_map::Entry, HashMap};

#[cfg(test)]
use chrono::offset::TimeZone;
use chrono::{DateTime, Utc};
#[cfg(test)]
use derivative::Derivative;
use serde::{Deserialize, Serialize};

Expand All @@ -13,7 +16,9 @@ use crate::{
},
};

#[derive(Default, Derivative, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
#[cfg_attr(test, derive(Derivative))]
#[cfg_attr(test, derivative(Default))]
#[serde(rename_all = "camelCase")]
pub struct NotificationsBucket {
#[serde(default)]
Expand All @@ -25,7 +30,7 @@ pub struct NotificationsBucket {
#[serde(default)]
pub last_updated: Option<DateTime<Utc>>,
/// The moment that the notification bucket was initialized.
#[derivative(Default(value = "Utc::now()"))]
#[cfg_attr(test, derivative(Default(value = "Utc.timestamp_opt(0, 0).unwrap()")))]
pub created: DateTime<Utc>,
}

Expand Down

0 comments on commit 0859574

Please sign in to comment.