diff --git a/src/model/song.rs b/src/model/song.rs index 8cfa8a3..ad340bc 100644 --- a/src/model/song.rs +++ b/src/model/song.rs @@ -64,7 +64,6 @@ use crate::subsonic; use adw::{prelude::*, subclass::prelude::*}; use glib::Object; use gtk::{gdk, glib}; -use std::rc::Rc; glib::wrapper! { pub struct Song(ObjectSubclass); @@ -72,10 +71,11 @@ glib::wrapper! { impl Song { pub fn from_child( - api: &Rc, + window: &crate::ui::Window, song: &subsonic::schema::Child, load_thumbnail: bool, ) -> Self { + let api = window.api(); let song: Song = Object::builder() .property("id", &song.id) .property("title", &song.title) @@ -88,14 +88,15 @@ impl Song { .build(); if load_thumbnail { - let api = Rc::clone(api); let id = song.id(); let song_weak = song.downgrade(); + let scale_factor = window.scale_factor() as u32; // NOTE: assumed constant song.imp() .thumbnail_loading .replace(Some(glib::spawn_future_local(async move { let bytes = api - .cover_art(&id, Some(50)) // TODO: WidgetExt::scale_factor + .cover_art(&id, Some(50 * scale_factor)) // see pixel-size in + // play_queue_song.blp .await .unwrap(); let song = match song_weak.upgrade() { diff --git a/src/ui/window.rs b/src/ui/window.rs index 5d46ed9..e474213 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -301,7 +301,7 @@ mod imp { Rc::clone(api.as_ref().unwrap()) }; for song in api.random_songs(10).await.unwrap().into_iter() { - let song = Song::from_child(&api, &song, true); + let song = Song::from_child(&self.obj(), &song, true); self.mpv .command(["loadfile", &song.stream_url(), "append-play"]) .unwrap();