gui: Sort folders by label, fall back to ids if required (fixes #3310)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3326
This commit is contained in:
Cedric Staniewski 2016-06-18 19:16:53 +00:00 committed by Jakob Borg
parent 20a94fafa7
commit 89a29946f9

View File

@ -49,10 +49,20 @@ function deviceCompare(a, b) {
} }
function folderCompare(a, b) { function folderCompare(a, b) {
if (a.id < b.id) { var labelA = a.id;
if (typeof a.label !== 'undefined' && a.label !== null && a.label.length > 0) {
labelA = a.label;
}
var labelB = b.id;
if (typeof b.label !== 'undefined' && b.label !== null && b.label.length > 0) {
labelB = b.label;
}
if (labelA < labelB) {
return -1; return -1;
} }
return a.id > b.id; return labelA > labelB;
} }
function folderMap(l) { function folderMap(l) {