From 02673a3d70b523e543e105fe175b3f7b192c7129 Mon Sep 17 00:00:00 2001 From: Spythere Date: Tue, 16 May 2023 14:27:31 +0200 Subject: [PATCH] =?UTF-8?q?poprawki=20filtr=C3=B3w=20scenerii?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/utils/filterUtils.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/store/utils/filterUtils.ts b/src/store/utils/filterUtils.ts index eaa3f88..7b5311c 100644 --- a/src/store/utils/filterUtils.ts +++ b/src/store/utils/filterUtils.ts @@ -29,29 +29,37 @@ export const sortStations = (a: Station, b: Station, sorter: { headerName: HeadI break; case 'user': - diff = - (a.onlineInfo?.currentUsers || a.onlineInfo?.maxUsers || 0) - - (b.onlineInfo?.currentUsers || b.onlineInfo?.maxUsers || 0); + diff = (b.onlineInfo ? b.onlineInfo.currentUsers : -1) - (a.onlineInfo ? a.onlineInfo.currentUsers : -1); break; case 'spawn': - diff = (a.onlineInfo?.spawns.length || 0) - (b.onlineInfo?.spawns.length || 0); + diff = (a.onlineInfo ? a.onlineInfo.spawns.length : -1) - (b.onlineInfo ? b.onlineInfo.spawns.length : -1); break; case 'timetableConfirmed': diff = - (a.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || 0) - - (b.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || 0); + (a.onlineInfo?.scheduledTrains + ? a.onlineInfo.scheduledTrains.filter((train) => train.stopInfo.confirmed).length + : -1) - + (b.onlineInfo?.scheduledTrains + ? b.onlineInfo.scheduledTrains.filter((train) => train.stopInfo.confirmed).length + : -1); break; case 'timetableUnconfirmed': diff = - (a.onlineInfo?.scheduledTrains?.filter((train) => !train.stopInfo.confirmed).length || 0) - - (b.onlineInfo?.scheduledTrains?.filter((train) => !train.stopInfo.confirmed).length || 0); + (a.onlineInfo?.scheduledTrains + ? a.onlineInfo.scheduledTrains.filter((train) => !train.stopInfo.confirmed).length + : -1) - + (b.onlineInfo?.scheduledTrains + ? b.onlineInfo.scheduledTrains.filter((train) => !train.stopInfo.confirmed).length + : -1); break; case 'timetableAll': - diff = (a.onlineInfo?.scheduledTrains?.length || 0) - (b.onlineInfo?.scheduledTrains?.length || 0); + diff = + (a.onlineInfo?.scheduledTrains ? a.onlineInfo.scheduledTrains.length : -1) - + (b.onlineInfo?.scheduledTrains ? b.onlineInfo.scheduledTrains.length : -1); break; default: