Refresh library when navigating back from video player
This commit is contained in:
@@ -6,7 +6,7 @@ mod media_list;
|
||||
mod media_tile;
|
||||
|
||||
use jellyfin_api::types::BaseItemDto;
|
||||
use relm4::ComponentController;
|
||||
use relm4::{ComponentController, SharedState};
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use adw::prelude::*;
|
||||
@@ -25,6 +25,8 @@ use crate::{
|
||||
|
||||
use self::home::{Home, HomeInit};
|
||||
|
||||
pub static LIBRARY_REFRESH_QUEUED: SharedState<bool> = SharedState::new();
|
||||
|
||||
enum LibraryState {
|
||||
Loading,
|
||||
Ready,
|
||||
@@ -41,6 +43,7 @@ pub struct Library {
|
||||
pub enum LibraryInput {
|
||||
MediaSelected(BaseItemDto),
|
||||
Refresh,
|
||||
Shown,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -149,6 +152,10 @@ impl Component for Library {
|
||||
add_setter: (&view_switcher_bar, "reveal", &true.into()),
|
||||
},
|
||||
},
|
||||
|
||||
connect_shown[sender] => move |_| {
|
||||
sender.input(LibraryInput::Shown);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,6 +212,12 @@ impl Component for Library {
|
||||
|
||||
self.initial_fetch(&sender);
|
||||
}
|
||||
LibraryInput::Shown => {
|
||||
if *LIBRARY_REFRESH_QUEUED.read() {
|
||||
sender.input(LibraryInput::Refresh);
|
||||
}
|
||||
*LIBRARY_REFRESH_QUEUED.write() = false;
|
||||
}
|
||||
}
|
||||
|
||||
self.update_view(widgets, sender);
|
||||
|
@@ -5,7 +5,9 @@ use std::{
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{globals::CONFIG, jellyfin_api::api_client::ApiClient};
|
||||
use crate::{
|
||||
globals::CONFIG, jellyfin_api::api_client::ApiClient, library::LIBRARY_REFRESH_QUEUED,
|
||||
};
|
||||
|
||||
use super::backends::VideoPlayerBackend;
|
||||
|
||||
@@ -18,6 +20,8 @@ pub fn start_session_reporting(
|
||||
|
||||
let position_update_frequency = config.video_player.position_update_frequency;
|
||||
|
||||
*LIBRARY_REFRESH_QUEUED.write() = true;
|
||||
|
||||
video_player
|
||||
.borrow_mut()
|
||||
.connect_position_updated(Box::new({
|
||||
|
@@ -11,6 +11,7 @@ use crate::app::{AppInput, APP_BROKER};
|
||||
use crate::globals::CONFIG;
|
||||
use crate::jellyfin_api::api::shows::GetEpisodesOptionsBuilder;
|
||||
use crate::jellyfin_api::api_client::ApiClient;
|
||||
use crate::library::LIBRARY_REFRESH_QUEUED;
|
||||
use crate::utils::ticks::ticks_to_seconds;
|
||||
use crate::video_player::controls::skip_forwards_backwards::{
|
||||
SkipForwardsBackwardsInput, SKIP_BACKWARDS_BROKER, SKIP_FORWARDS_BROKER,
|
||||
@@ -317,6 +318,7 @@ impl Component for VideoPlayer {
|
||||
.report_playback_stopped(&item_id, position)
|
||||
.await
|
||||
.unwrap();
|
||||
*LIBRARY_REFRESH_QUEUED.write() = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user