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,11 +88,19 @@ impl EventHandler for MPDDisplay {
if self.is_valid && self.is_initialized && self.poll_instant.elapsed() > POLL_TIME { if self.is_valid && self.is_initialized && self.poll_instant.elapsed() > POLL_TIME {
self.poll_instant = Instant::now(); self.poll_instant = Instant::now();
self.shared = MPDHandler::get_current_song_info(self.mpd_handler.clone().unwrap()) if !self.dirty_flag.is_none()
.map_or(None, |f| Some(f)); && self
if let Some(shared) = &self.shared { .dirty_flag
if self.notice_text.contents() != shared.error_text { .as_ref()
self.notice_text = Text::new(TextFragment::new(shared.error_text.clone())); .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 {
if self.notice_text.contents() != shared.error_text {
self.notice_text = Text::new(TextFragment::new(shared.error_text.clone()));
}
} }
} }
} }