closes #9
This commit is contained in:
psykose 2024-11-19 14:03:40 +01:00
parent a72db0880b
commit 3fcb88c056
Signed by: psykose
SSH key fingerprint: SHA256:pRMVjV3kRB6zl+wNx+sV8KoMnPqQAW6v8dNCxsCGZv8

View file

@ -1,8 +1,7 @@
use crate::model::{Album, Song};
use crate::model::Song;
use crate::{mpris, mpv};
use adw::prelude::*;
use adw::subclass::prelude::*;
use futures::TryStreamExt;
use glib::subclass::InitializingObject;
use glib::JoinHandle;
use gtk::{gdk, gio, glib};
@ -54,9 +53,6 @@ mod imp {
#[property(get)]
playlist_model: gio::ListStore,
#[property(get)]
albums_model: gio::ListStore,
#[property(type = i64, get = Self::volume, set = Self::set_volume)]
_volume: (),
#[property(type = bool, get = Self::mute, set = Self::set_mute)]
@ -126,7 +122,6 @@ mod imp {
mpv,
playlist_model: gio::ListStore::new::<Song>(),
albums_model: gio::ListStore::new::<Album>(),
_volume: (),
_mute: (),
@ -798,37 +793,6 @@ mod imp {
// cancel queued seek always
self.queued_seek.set(None);
}
#[template_callback]
pub(super) async fn on_refresh_albums_clicked(&self) {
self.obj().set_refreshing_albums(true);
self.albums_model.remove_all();
let api = Rc::clone(self.api.borrow().as_ref().unwrap());
let albums_model = self.obj().albums_model().clone();
let perform = async move {
let mut albums =
std::pin::pin!(api.album_list_full(crate::subsonic::AlbumListType::Newest));
while let Some(album) = albums.try_next().await? {
albums_model.append(
&glib::Object::builder::<crate::model::Album>()
.property("id", &album.id)
.property("name", &album.name)
.property("artist", &album.artist)
.build(),
);
}
Ok::<(), crate::subsonic::Error>(())
};
match perform.await {
Ok(()) => {}
Err(err) => event!(Level::ERROR, "could not refresh album list: {err}"),
}
self.obj().set_refreshing_albums(false);
}
}
impl Drop for Window {
@ -904,9 +868,6 @@ impl Window {
}
self.set_can_click_shuffle_all(true);
let window = self.clone();
glib::spawn_future_local(async move { window.imp().on_refresh_albums_clicked().await });
}
pub fn playlist_next(&self) {