Skip to content

Commit

Permalink
feat: use the playing info first
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Aug 26, 2024
1 parent bcb1ccd commit a748c70
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lala_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,19 +519,24 @@ impl From<NotifyMessage> for Message {

async fn get_metadata_initial() -> Option<ServiceInfo> {
zbus_mpirs::init_mpirs().await.ok();
let infos = zbus_mpirs::MPIRS_CONNECTIONS.lock().await;
infos
.iter()
.find(|info| !info.metadata.xesam_title.is_empty())
.cloned()
get_metadata().await
}

async fn get_metadata() -> Option<ServiceInfo> {
let infos = zbus_mpirs::MPIRS_CONNECTIONS.lock().await;
infos

let alive_infos: Vec<&ServiceInfo> = infos
.iter()
.find(|info| !info.metadata.xesam_title.is_empty())
.cloned()
.filter(|info| !info.metadata.xesam_title.is_empty())
.collect();

if let Some(playingserver) = alive_infos
.iter()
.find(|info| info.playback_status == "Playing")
{
return Some((*playingserver).clone());
}
alive_infos.first().cloned().cloned()
}

impl LalaMusicBar {
Expand Down

0 comments on commit a748c70

Please sign in to comment.