media library: add data fetch delay after position changes
This commit is contained in:
@@ -2784,11 +2784,16 @@ void listsChangeFinisher()
|
|||||||
if (myScreen->activeWindow() == &myLibrary->Tags)
|
if (myScreen->activeWindow() == &myLibrary->Tags)
|
||||||
{
|
{
|
||||||
myLibrary->Albums.clear();
|
myLibrary->Albums.clear();
|
||||||
|
myLibrary->Albums.refresh();
|
||||||
myLibrary->Songs.clear();
|
myLibrary->Songs.clear();
|
||||||
|
myLibrary->Songs.refresh();
|
||||||
|
myLibrary->updateTimer();
|
||||||
}
|
}
|
||||||
else if (myScreen->activeWindow() == &myLibrary->Albums)
|
else if (myScreen->activeWindow() == &myLibrary->Albums)
|
||||||
{
|
{
|
||||||
myLibrary->Songs.clear();
|
myLibrary->Songs.clear();
|
||||||
|
myLibrary->Songs.refresh();
|
||||||
|
myLibrary->updateTimer();
|
||||||
}
|
}
|
||||||
else if (myScreen->isActiveWindow(myPlaylistEditor->Playlists))
|
else if (myScreen->isActiveWindow(myPlaylistEditor->Playlists))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ using Global::myScreen;
|
|||||||
|
|
||||||
MediaLibrary *myLibrary;
|
MediaLibrary *myLibrary;
|
||||||
|
|
||||||
namespace {//
|
namespace {
|
||||||
|
|
||||||
|
const auto fetch_delay = boost::posix_time::milliseconds(500);
|
||||||
|
|
||||||
bool hasTwoColumns;
|
bool hasTwoColumns;
|
||||||
size_t itsLeftColStartX;
|
size_t itsLeftColStartX;
|
||||||
@@ -144,6 +146,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MediaLibrary::MediaLibrary()
|
MediaLibrary::MediaLibrary()
|
||||||
|
: m_timer(boost::posix_time::from_time_t(0))
|
||||||
{
|
{
|
||||||
hasTwoColumns = 0;
|
hasTwoColumns = 0;
|
||||||
itsLeftColWidth = COLS/3-1;
|
itsLeftColWidth = COLS/3-1;
|
||||||
@@ -336,7 +339,9 @@ void MediaLibrary::update()
|
|||||||
Tags.refresh();
|
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();
|
Albums.clearSearchResults();
|
||||||
m_albums_update_request = false;
|
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();
|
Songs.clearSearchResults();
|
||||||
m_songs_update_request = false;
|
m_songs_update_request = false;
|
||||||
@@ -851,6 +858,11 @@ void MediaLibrary::nextColumn()
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
|
void MediaLibrary::updateTimer()
|
||||||
|
{
|
||||||
|
m_timer = Global::Timer;
|
||||||
|
}
|
||||||
|
|
||||||
void MediaLibrary::toggleColumnsMode()
|
void MediaLibrary::toggleColumnsMode()
|
||||||
{
|
{
|
||||||
hasTwoColumns = !hasTwoColumns;
|
hasTwoColumns = !hasTwoColumns;
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ struct MediaLibrary: Screen<NC::Window *>, Filterable, HasColumns, HasSongs, Sea
|
|||||||
virtual void nextColumn() OVERRIDE;
|
virtual void nextColumn() OVERRIDE;
|
||||||
|
|
||||||
// private members
|
// private members
|
||||||
|
void updateTimer();
|
||||||
void toggleColumnsMode();
|
void toggleColumnsMode();
|
||||||
int Columns();
|
int Columns();
|
||||||
void LocateSong(const MPD::Song &);
|
void LocateSong(const MPD::Song &);
|
||||||
@@ -143,6 +144,8 @@ private:
|
|||||||
bool m_tags_update_request;
|
bool m_tags_update_request;
|
||||||
bool m_albums_update_request;
|
bool m_albums_update_request;
|
||||||
bool m_songs_update_request;
|
bool m_songs_update_request;
|
||||||
|
|
||||||
|
boost::posix_time::ptime m_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MediaLibrary *myLibrary;
|
extern MediaLibrary *myLibrary;
|
||||||
|
|||||||
Reference in New Issue
Block a user