trendingStatusesController: sort events in the order they appear in the label

This commit is contained in:
Alex Gleason 2024-06-02 12:07:45 -05:00
parent 0f59b3c96b
commit 45d9a113c3
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 0 deletions

View File

@ -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<Record<string, number>>((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, {})),
);