Sort Grooveshark favorite songs according to "TSFavorited", as such songs have no "Sort" field.

BTW the compare was buggy (didn't compare against song2). This was OK though, as
we stable sort songs, and they are always ordered as far as I know (I remember
adding this sort just in case they will not be sent ordered on day).
This commit is contained in:
Arnaud Bienner 2014-12-10 22:43:16 +01:00
parent fb5181a6e9
commit 4b48be4a5b
1 changed files with 9 additions and 1 deletions

View File

@ -1717,7 +1717,15 @@ QVariantMap GroovesharkService::ExtractResult(QNetworkReply* reply) {
namespace {
bool CompareSongs(const QVariant& song1, const QVariant& song2) {
return song1.toMap()["Sort"].toInt() < song1.toMap()["Sort"].toInt();
QMap<QString, QVariant> song1_map = song1.toMap();
QMap<QString, QVariant> song2_map = song2.toMap();
int song1_sort = song1_map["Sort"].toInt();
int song2_sort = song2_map["Sort"].toInt();
if (song1_sort == song2_sort) {
// Favorite songs have a "TSFavorited" and (currently) no "Sort" field
return song1_map["TSFavorited"].toString() < song2_map["TSFavorited"].toString();
}
return song1_sort < song2_sort;
}
}