From d35cf6a7fb01bc249954d0c91568befb6b333c18 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 6 Sep 2014 15:12:47 +0200 Subject: [PATCH] media library: toggle sort more: fetch data only if mtimes are not there --- src/media_library.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/media_library.cpp b/src/media_library.cpp index 84686c2e..d398e4c0 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -919,20 +919,32 @@ void MediaLibrary::toggleSortMode() Config.media_library_sort_by_mtime ? "modification time" : "name"); if (hasTwoColumns) { - std::sort(Albums.beginV(), Albums.endV(), SortAlbumEntries()); + withUnfilteredMenuReapplyFilter(Albums, [this]() { + std::sort(Albums.beginV(), Albums.endV(), SortAlbumEntries()); + }); Albums.refresh(); Songs.clear(); if (Config.titles_visibility) { std::string item_type = boost::locale::to_lower( tagTypeToString(Config.media_lib_primary_tag)); - std::string and_mtime = Config.media_library_sort_by_mtime ? " and mtime" : ""; + std::string and_mtime = Config.media_library_sort_by_mtime ? (" " "and mtime") : ""; Albums.setTitle("Albums (sorted by " + item_type + and_mtime + ")"); } } else { - Tags.clear(); + withUnfilteredMenuReapplyFilter(Tags, [this]() { + // if we already have modification times, + // just resort. otherwise refetch the list. + if (!Tags.empty() && Tags[0].value().mtime() > 0) + { + std::sort(Tags.beginV(), Tags.endV(), SortPrimaryTags()); + Tags.refresh(); + } + else + Tags.clear(); + }); Albums.clear(); Songs.clear(); }