From 45d9a113c3dadd2b39e94dd521a8b5a9cc7a5ea4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 2 Jun 2024 12:07:45 -0500 Subject: [PATCH] trendingStatusesController: sort events in the order they appear in the label --- src/controllers/api/trends.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/controllers/api/trends.ts b/src/controllers/api/trends.ts index 4fd92d1c..b6813730 100644 --- a/src/controllers/api/trends.ts +++ b/src/controllers/api/trends.ts @@ -95,6 +95,10 @@ const trendingStatusesController: AppController = async (c) => { const events = await store.query([{ ids }]) .then((events) => hydrateEvents({ events, store })); + // Sort events in the order they appear in the label. + const indexes = ids.reduce>((acc, id, index) => ({ ...acc, [id]: index }), {}); + events.sort((a, b) => indexes[a.id] - indexes[b.id]); + const statuses = await Promise.all( events.map((event) => renderStatus(event, {})), );