Skip to content

Commit

Permalink
add dismissed events bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeastLT committed Dec 15, 2023
1 parent 5406581 commit 5c8a6d8
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 36 deletions.
3 changes: 3 additions & 0 deletions src/commonMain/rust/bridge/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ impl FromProtobuf<Action> for runtime::Action {
Action::Ctx(ActionCtx::PullNotifications)
}
Some(action_ctx::Args::GetEvents(_args)) => Action::Ctx(ActionCtx::GetEvents),
Some(action_ctx::Args::DismissEvent(id)) => {
Action::Ctx(ActionCtx::DismissEvent(id.to_owned()))
}
None => unimplemented!("ActionCtx missing"),
},
Some(runtime::action::Type::Link(action_link)) => match &action_link.args {
Expand Down
5 changes: 5 additions & 0 deletions src/commonMain/rust/bridge/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ impl ToProtobuf<runtime::Event, ()> for Event {
runtime::event::NotificationsPushedToStorage { ids: ids.clone() },
)
}
Event::DismissedEventsPushedToStorage { uid } => {
runtime::event::Type::DismissedEventsPushedToStorage(
runtime::event::DismissedEventsPushedToStorage { uid: uid.clone() },
)
}
Event::UserPulledFromAPI { uid } => {
runtime::event::Type::UserPulledFromApi(runtime::event::UserPulledFromApi {
uid: uid.clone(),
Expand Down
11 changes: 10 additions & 1 deletion src/commonMain/rust/model/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use stremio_core::models::player::Player;
use stremio_core::models::streaming_server::StreamingServer;
use stremio_core::runtime::Effects;
use stremio_core::types::api::LinkAuthKey;
use stremio_core::types::events::DismissedEventsBucket;
use stremio_core::types::library::LibraryBucket;
use stremio_core::types::notifications::NotificationsBucket;
use stremio_core::types::profile::Profile;
Expand Down Expand Up @@ -49,11 +50,19 @@ impl AndroidModel {
streams: StreamsBucket,
notifications: NotificationsBucket,
search_history: SearchHistoryBucket,
dismissed_events: DismissedEventsBucket,
) -> (AndroidModel, Effects) {
let (continue_watching_preview, continue_watching_preview_effects) =
ContinueWatchingPreview::new(&library, &notifications);

let ctx = Ctx::new(profile, library, streams, notifications, search_history);
let ctx = Ctx::new(
profile,
library,
streams,
notifications,
search_history,
dismissed_events,
);

let (discover, discover_effects) = CatalogWithFilters::<MetaItemPreview>::new(&ctx.profile);
let (library_, library_effects) =
Expand Down
22 changes: 17 additions & 5 deletions src/commonMain/rust/stremio_core_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ use jni::{JNIEnv, JavaVM};
use lazy_static::lazy_static;
use prost::Message;
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,
};
use stremio_core::models::common::Loadable;
use stremio_core::runtime::{Env, EnvError, Runtime, RuntimeEvent};
use stremio_core::types::events::DismissedEventsBucket;
use stremio_core::types::library::LibraryBucket;
use stremio_core::types::notifications::NotificationsBucket;
use stremio_core::types::profile::Profile;
Expand Down Expand Up @@ -59,7 +61,7 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative(
let init_result = AndroidEnv::exec_sync(AndroidEnv::init(&env, storage));
match init_result {
Ok(_) => {
let storage_result = AndroidEnv::exec_sync(future::try_join(
let storage_result = AndroidEnv::exec_sync(future::try_join3(
future::try_join5(
AndroidEnv::get_storage::<Profile>(PROFILE_STORAGE_KEY),
AndroidEnv::get_storage::<LibraryBucket>(LIBRARY_RECENT_STORAGE_KEY),
Expand All @@ -68,11 +70,13 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative(
AndroidEnv::get_storage::<NotificationsBucket>(NOTIFICATIONS_STORAGE_KEY),
),
AndroidEnv::get_storage::<SearchHistoryBucket>(SEARCH_HISTORY_STORAGE_KEY),
AndroidEnv::get_storage::<DismissedEventsBucket>(DISMISSED_EVENTS_STORAGE_KEY),
));
match storage_result {
Ok((
(profile, recent_bucket, other_bucket, streams, notifications),
search_history,
dismissed_events,
)) => {
let profile = profile.unwrap_or_default();
let mut library = LibraryBucket::new(profile.uid(), vec![]);
Expand All @@ -90,8 +94,16 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative(
));
let search_history =
search_history.unwrap_or(SearchHistoryBucket::new(profile.uid()));
let (model, effects) =
AndroidModel::new(profile, library, streams, notifications, search_history);
let dismissed_events =
dismissed_events.unwrap_or(DismissedEventsBucket::new(profile.uid()));
let (model, effects) = AndroidModel::new(
profile,
library,
streams,
notifications,
search_history,
dismissed_events,
);
let (runtime, rx) = Runtime::<AndroidEnv, _>::new(
model,
effects.into_iter().collect::<Vec<_>>(),
Expand Down
1 change: 1 addition & 0 deletions src/main/proto/stremio/core/runtime/action_ctx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ message ActionCtx {
google.protobuf.Empty sync_library_with_api = 18;
google.protobuf.Empty pull_notifications = 19;
google.protobuf.Empty get_events = 20;
string dismiss_event = 21;
}

message LibraryItemToggle {
Expand Down
64 changes: 34 additions & 30 deletions src/main/proto/stremio/core/runtime/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,37 @@ message Event {
StreamsPushedToStorage streams_pushed_to_storage = 3;
SearchHistoryPushedToStorage search_history_pushed_to_storage = 4;
NotificationsPushedToStorage notifications_pushed_to_storage = 5;
UserPulledFromAPI user_pulled_from_api = 6;
UserPushedToAPI user_pushed_to_api = 7;
AddonsPulledFromAPI addons_pulled_from_api = 8;
AddonsPushedToAPI addons_pushed_to_api = 9;
LibrarySyncWithAPIPlanned library_sync_with_api_planned = 10;
LibraryItemsPushedToAPI library_items_pushed_to_api = 11;
LibraryItemsPulledFromAPI library_items_pulled_from_api = 12;
UserAuthenticated user_authenticated = 13;
UserLoggedOut user_logged_out = 14;
SessionDeleted session_deleted = 15;
TraktAddonFetched trakt_addon_fetched = 16;
TraktLoggedOut trakt_logged_out = 17;
AddonInstalled addon_installed = 18;
AddonUpgraded addon_upgraded = 19;
AddonUninstalled addon_uninstalled = 20;
SettingsUpdated settings_updated = 21;
LibraryItemAdded library_item_added = 22;
LibraryItemRemoved library_item_removed = 23;
LibraryItemRewinded library_item_rewinded = 24;
LibraryItemNotificationsToggled library_item_notifications_toggled = 25;
NotificationsDismissed notifications_dismissed = 26;
PlayerPlaying player_playing = 27;
PlayerStopped player_stopped = 28;
PlayerNextVideo player_next_video = 29;
PlayerEnded player_ended = 30;
TraktPlaying trakt_playing = 31;
TraktPaused trakt_paused = 32;
MagnetParsed magnet_parsed = 33;
TorrentParsed torrent_parsed = 34;
PlayingOnDevice playing_on_device = 35;
DismissedEventsPushedToStorage dismissed_events_pushed_to_storage = 6;
UserPulledFromAPI user_pulled_from_api = 7;
UserPushedToAPI user_pushed_to_api = 8;
AddonsPulledFromAPI addons_pulled_from_api = 9;
AddonsPushedToAPI addons_pushed_to_api = 10;
LibrarySyncWithAPIPlanned library_sync_with_api_planned = 11;
LibraryItemsPushedToAPI library_items_pushed_to_api = 12;
LibraryItemsPulledFromAPI library_items_pulled_from_api = 13;
UserAuthenticated user_authenticated = 14;
UserLoggedOut user_logged_out = 15;
SessionDeleted session_deleted = 16;
TraktAddonFetched trakt_addon_fetched = 17;
TraktLoggedOut trakt_logged_out = 18;
AddonInstalled addon_installed = 19;
AddonUpgraded addon_upgraded = 20;
AddonUninstalled addon_uninstalled = 21;
SettingsUpdated settings_updated = 22;
LibraryItemAdded library_item_added = 23;
LibraryItemRemoved library_item_removed = 24;
LibraryItemRewinded library_item_rewinded = 25;
LibraryItemNotificationsToggled library_item_notifications_toggled = 26;
NotificationsDismissed notifications_dismissed = 27;
PlayerPlaying player_playing = 28;
PlayerStopped player_stopped = 29;
PlayerNextVideo player_next_video = 30;
PlayerEnded player_ended = 31;
TraktPlaying trakt_playing = 32;
TraktPaused trakt_paused = 33;
MagnetParsed magnet_parsed = 34;
TorrentParsed torrent_parsed = 35;
PlayingOnDevice playing_on_device = 36;
Error error = 100;
}

Expand All @@ -62,6 +63,9 @@ message Event {
message NotificationsPushedToStorage {
repeated string ids = 1;
}
message DismissedEventsPushedToStorage {
optional string uid = 1;
}
message UserPulledFromAPI {
optional string uid = 1;
}
Expand Down

0 comments on commit 5c8a6d8

Please sign in to comment.