From a34a1be52dc6b08f6691845487a7dfc843e774e3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 13 Aug 2022 07:18:59 -0700 Subject: Add name sorting (fix #1015) --- modern/src/main/MainPage.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modern/src/main/MainPage.js b/modern/src/main/MainPage.js index 283c61a6..a09d9f87 100644 --- a/modern/src/main/MainPage.js +++ b/modern/src/main/MainPage.js @@ -199,6 +199,20 @@ const MainPage = () => { const keyword = filterKeyword.toLowerCase(); return [device.name, device.uniqueId, device.phone, device.model, device.contact].some((s) => s && s.toLowerCase().includes(keyword)); }); + switch (filterSort) { + case 'name': + filtered.sort((device1, device2) => device1.name.localeCompare(device2.name)); + break; + case 'lastUpdate': + filtered.sort((device1, device2) => { + const time1 = device1.lastUpdate ? moment(device1.lastUpdate).valueOf() : 0; + const time2 = device2.lastUpdate ? moment(device2.lastUpdate).valueOf() : 0; + return time2 - time1; + }); + break; + default: + break; + } if (filterSort === 'lastUpdate') { filtered.sort((device1, device2) => { const time1 = device1.lastUpdate ? moment(device1.lastUpdate).valueOf() : 0; @@ -311,6 +325,7 @@ const MainPage = () => { displayEmpty > {'\u00a0'} + {t('sharedName')} {t('deviceLastUpdate')} -- cgit v1.2.3