diff --git a/src/actions.cpp b/src/actions.cpp index 22229951..046d7011 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -2784,11 +2784,16 @@ void listsChangeFinisher() if (myScreen->activeWindow() == &myLibrary->Tags) { myLibrary->Albums.clear(); + myLibrary->Albums.refresh(); myLibrary->Songs.clear(); + myLibrary->Songs.refresh(); + myLibrary->updateTimer(); } else if (myScreen->activeWindow() == &myLibrary->Albums) { myLibrary->Songs.clear(); + myLibrary->Songs.refresh(); + myLibrary->updateTimer(); } else if (myScreen->isActiveWindow(myPlaylistEditor->Playlists)) { diff --git a/src/media_library.cpp b/src/media_library.cpp index 76e89fa3..de75818d 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -45,7 +45,9 @@ using Global::myScreen; MediaLibrary *myLibrary; -namespace {// +namespace { + +const auto fetch_delay = boost::posix_time::milliseconds(500); bool hasTwoColumns; size_t itsLeftColStartX; @@ -144,6 +146,7 @@ public: } MediaLibrary::MediaLibrary() +: m_timer(boost::posix_time::from_time_t(0)) { hasTwoColumns = 0; itsLeftColWidth = COLS/3-1; @@ -336,7 +339,9 @@ void MediaLibrary::update() Tags.refresh(); } - if ((!Tags.empty() && Albums.reallyEmpty()) || m_albums_update_request) + if (!Tags.empty() + && ((Albums.reallyEmpty() && Global::Timer - m_timer > fetch_delay) || m_albums_update_request) + ) { Albums.clearSearchResults(); m_albums_update_request = false; @@ -382,7 +387,9 @@ void MediaLibrary::update() } } - if ((!Albums.empty() && Songs.reallyEmpty()) || m_songs_update_request) + if (!Albums.empty() + && ((Songs.reallyEmpty() && Global::Timer - m_timer > fetch_delay) || m_songs_update_request) + ) { Songs.clearSearchResults(); m_songs_update_request = false; @@ -851,6 +858,11 @@ void MediaLibrary::nextColumn() /***********************************************************************/ +void MediaLibrary::updateTimer() +{ + m_timer = Global::Timer; +} + void MediaLibrary::toggleColumnsMode() { hasTwoColumns = !hasTwoColumns; diff --git a/src/media_library.h b/src/media_library.h index 2b6dfcc7..6ce94931 100644 --- a/src/media_library.h +++ b/src/media_library.h @@ -69,6 +69,7 @@ struct MediaLibrary: Screen, Filterable, HasColumns, HasSongs, Sea virtual void nextColumn() OVERRIDE; // private members + void updateTimer(); void toggleColumnsMode(); int Columns(); void LocateSong(const MPD::Song &); @@ -143,6 +144,8 @@ private: bool m_tags_update_request; bool m_albums_update_request; bool m_songs_update_request; + + boost::posix_time::ptime m_timer; }; extern MediaLibrary *myLibrary;