From 89a29946f96c63795ca5d3da062316c375604961 Mon Sep 17 00:00:00 2001 From: Cedric Staniewski Date: Sat, 18 Jun 2016 19:16:53 +0000 Subject: [PATCH] gui: Sort folders by label, fall back to ids if required (fixes #3310) GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3326 --- gui/default/syncthing/app.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gui/default/syncthing/app.js b/gui/default/syncthing/app.js index 576de8d85..c17042875 100644 --- a/gui/default/syncthing/app.js +++ b/gui/default/syncthing/app.js @@ -49,10 +49,20 @@ function deviceCompare(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 a.id > b.id; + return labelA > labelB; } function folderMap(l) {