add alpha as second sorting condition for device list (#9665)

This commit is contained in:
Kerry 2022-12-01 16:21:39 +13:00 committed by GitHub
parent b0dfb2262e
commit 5583d07f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,12 +64,13 @@ const isDeviceSelected = (
) => selectedDeviceIds.includes(deviceId); ) => selectedDeviceIds.includes(deviceId);
// devices without timestamp metadata should be sorted last // devices without timestamp metadata should be sorted last
const sortDevicesByLatestActivity = (left: ExtendedDevice, right: ExtendedDevice) => const sortDevicesByLatestActivityThenDisplayName = (left: ExtendedDevice, right: ExtendedDevice) =>
(right.last_seen_ts || 0) - (left.last_seen_ts || 0); (right.last_seen_ts || 0) - (left.last_seen_ts || 0)
|| ((left.display_name || left.device_id).localeCompare(right.display_name || right.device_id));
const getFilteredSortedDevices = (devices: DevicesDictionary, filter?: DeviceSecurityVariation) => const getFilteredSortedDevices = (devices: DevicesDictionary, filter?: DeviceSecurityVariation) =>
filterDevicesBySecurityRecommendation(Object.values(devices), filter ? [filter] : []) filterDevicesBySecurityRecommendation(Object.values(devices), filter ? [filter] : [])
.sort(sortDevicesByLatestActivity); .sort(sortDevicesByLatestActivityThenDisplayName);
const ALL_FILTER_ID = 'ALL'; const ALL_FILTER_ID = 'ALL';
type DeviceFilterKey = DeviceSecurityVariation | typeof ALL_FILTER_ID; type DeviceFilterKey = DeviceSecurityVariation | typeof ALL_FILTER_ID;