Skip to content

Commit

Permalink
update item page after playing video
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukinaha committed Oct 7, 2024
1 parent c808c8f commit 8352f87
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/ui/mpv/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,11 +898,14 @@ impl MPVPage {
spawn_g_timeout(glib::clone!(
#[weak(rename_to = obj)]
self,
#[weak]
window,
async move {
if let Some(timeout) = obj.imp().timeout.take() {
glib::source::SourceId::remove(timeout);
}
obj.set_reveal_overlay(true);
window.update_item_page().await;
}
));
}
Expand Down
3 changes: 1 addition & 2 deletions src/ui/widgets/horbu_scrolled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl HorbuScrolled {
imp.revealer.set_reveal_child(true);

let flow = imp.flow.get();
flow.remove_all();

spawn(glib::clone!(
#[weak]
Expand All @@ -151,8 +152,6 @@ impl HorbuScrolled {
});

flow.append(&button);

gtk::glib::timeout_future(std::time::Duration::from_millis(30)).await;
}
}
));
Expand Down
21 changes: 20 additions & 1 deletion src/ui/widgets/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,24 @@ impl ItemPage {
}
}

pub async fn update_intro(&self) {
let item = self.item();
let series_id = item.series_id().unwrap_or(item.id());

spawn(glib::clone!(
#[weak(rename_to = obj)]
self,
#[strong]
series_id,
async move {
let Some(intro) = obj.set_shows_next_up(&series_id).await else {
return;
};
obj.set_intro::<false>(&intro).await;
}
));
}

async fn setup_item(&self, id: &str) {
let id = id.to_string();
let id_clone = id.clone();
Expand Down Expand Up @@ -553,7 +571,8 @@ impl ItemPage {
));

for media in &playbackinfo.media_sources {
let line2 = media.bit_rate
let line2 = media
.bit_rate
.map(|bit_rate| format!("{:.2} Kbps", bit_rate as f64 / 1_000.0))
.unwrap_or_default();
let Ok(dl) = DropdownListBuilder::default()
Expand Down
11 changes: 11 additions & 0 deletions src/ui/widgets/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ use glib::Object;
use gtk::{gio, glib, template_callbacks};

use super::home::HomePage;
use super::item::ItemPage;
use super::liked::LikedPage;
use super::search::SearchPage;
use super::server_action_row;
Expand Down Expand Up @@ -962,4 +963,14 @@ impl Window {
app.uninhibit(cookie);
}
}

pub async fn update_item_page(&self) {
let imp = self.imp();
let nav = imp.mainview.visible_page();
let Some(now_page) = nav.and_downcast_ref::<ItemPage>() else {
return;
};

now_page.update_intro().await;
}
}

0 comments on commit 8352f87

Please sign in to comment.