Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Serialize ctx events & implement dismissed events bucket #80

Merged
merged 8 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions src/model/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use stremio_core::{
},
runtime::Effects,
types::{
addon::DescriptorPreview, api::LinkAuthKey, library::LibraryBucket,
notifications::NotificationsBucket, profile::Profile, resource::MetaItemPreview,
search_history::SearchHistoryBucket, streams::StreamsBucket,
addon::DescriptorPreview, api::LinkAuthKey, events::DismissedEventsBucket,
library::LibraryBucket, notifications::NotificationsBucket, profile::Profile,
resource::MetaItemPreview, search_history::SearchHistoryBucket, streams::StreamsBucket,
},
Model,
};
Expand Down Expand Up @@ -68,6 +68,7 @@ impl WebModel {
streams: StreamsBucket,
notifications: NotificationsBucket,
search_history: SearchHistoryBucket,
dismissed_events: DismissedEventsBucket,
) -> (WebModel, Effects) {
let (continue_watching_preview, continue_watching_preview_effects) =
ContinueWatchingPreview::new(&library, &notifications);
Expand All @@ -83,7 +84,14 @@ impl WebModel {
let (streaming_server, streaming_server_effects) = StreamingServer::new::<WebEnv>(&profile);
let (local_search, local_search_effects) = LocalSearch::new::<WebEnv>();
let model = WebModel {
ctx: Ctx::new(profile, library, streams, notifications, search_history),
ctx: Ctx::new(
profile,
library,
streams,
notifications,
search_history,
dismissed_events,
),
auth_link: Default::default(),
data_export: Default::default(),
local_search,
Expand Down
6 changes: 5 additions & 1 deletion src/model/serialize_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ mod model {

use stremio_core::{
deep_links::SearchHistoryItemDeepLinks,
types::{notifications::NotificationItem, profile::Profile, resource::MetaItemId},
types::{
events::Events, notifications::NotificationItem, profile::Profile, resource::MetaItemId,
},
};

#[derive(Serialize)]
Expand All @@ -26,6 +28,7 @@ mod model {
pub profile: &'a Profile,
pub notifications: Notifications<'a>,
pub search_history: Vec<SearchHistoryItem<'a>>,
pub events: &'a Events,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -70,6 +73,7 @@ mod model {
deep_links: SearchHistoryItemDeepLinks::from(query),
})
.collect(),
events: &ctx.events,
}
}
}
Expand Down
15 changes: 11 additions & 4 deletions src/stremio_core_web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ use wasm_bindgen::JsValue;

use stremio_core::{
constants::{
LIBRARY_RECENT_STORAGE_KEY, LIBRARY_STORAGE_KEY, NOTIFICATIONS_STORAGE_KEY,
PROFILE_STORAGE_KEY, SEARCH_HISTORY_STORAGE_KEY, STREAMS_STORAGE_KEY,
DISMISSED_EVENTS_STORAGE_KEY, LIBRARY_RECENT_STORAGE_KEY, LIBRARY_STORAGE_KEY,
NOTIFICATIONS_STORAGE_KEY, PROFILE_STORAGE_KEY, SEARCH_HISTORY_STORAGE_KEY,
STREAMS_STORAGE_KEY,
},
models::common::Loadable,
runtime::{msg::Action, Env, EnvError, Runtime, RuntimeAction, RuntimeEvent},
types::{
library::LibraryBucket, notifications::NotificationsBucket, profile::Profile,
resource::Stream, search_history::SearchHistoryBucket, streams::StreamsBucket,
events::DismissedEventsBucket, library::LibraryBucket, notifications::NotificationsBucket,
profile::Profile, resource::Stream, search_history::SearchHistoryBucket,
streams::StreamsBucket,
},
};

Expand Down Expand Up @@ -65,6 +67,7 @@ pub async fn initialize_runtime(emit_to_ui: js_sys::Function) -> Result<(), JsVa
WebEnv::get_storage::<StreamsBucket>(STREAMS_STORAGE_KEY),
WebEnv::get_storage::<NotificationsBucket>(NOTIFICATIONS_STORAGE_KEY),
WebEnv::get_storage::<SearchHistoryBucket>(SEARCH_HISTORY_STORAGE_KEY),
WebEnv::get_storage::<DismissedEventsBucket>(DISMISSED_EVENTS_STORAGE_KEY),
);
match storage_result {
Ok((
Expand All @@ -74,6 +77,7 @@ pub async fn initialize_runtime(emit_to_ui: js_sys::Function) -> Result<(), JsVa
streams_bucket,
notifications_bucket,
search_history_bucket,
dismissed_events_bucket,
)) => {
let profile = profile.unwrap_or_default();
let mut library = LibraryBucket::new(profile.uid(), vec![]);
Expand All @@ -89,12 +93,15 @@ pub async fn initialize_runtime(emit_to_ui: js_sys::Function) -> Result<(), JsVa
.unwrap_or(NotificationsBucket::new::<WebEnv>(profile.uid(), vec![]));
let search_history_bucket =
search_history_bucket.unwrap_or(SearchHistoryBucket::new(profile.uid()));
let dismissed_events_bucket = dismissed_events_bucket
.unwrap_or(DismissedEventsBucket::new(profile.uid()));
let (model, effects) = WebModel::new(
profile,
library,
streams_bucket,
notifications_bucket,
search_history_bucket,
dismissed_events_bucket,
);
let (runtime, rx) = Runtime::<WebEnv, _>::new(
model,
Expand Down