WIP only update display if dirty_flag is set

This commit is contained in:
Stephen Seo 2021-12-15 14:36:56 +09:00
parent 866e88ba2a
commit 796ad86f19

View file

@ -88,6 +88,13 @@ impl EventHandler for MPDDisplay {
if self.is_valid && self.is_initialized && self.poll_instant.elapsed() > POLL_TIME {
self.poll_instant = Instant::now();
if !self.dirty_flag.is_none()
&& self
.dirty_flag
.as_ref()
.unwrap()
.swap(false, std::sync::atomic::Ordering::Relaxed)
{
self.shared = MPDHandler::get_current_song_info(self.mpd_handler.clone().unwrap())
.map_or(None, |f| Some(f));
if let Some(shared) = &self.shared {
@ -96,6 +103,7 @@ impl EventHandler for MPDDisplay {
}
}
}
}
Ok(())
}