mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
trendingStatusesController: sort events in the order they appear in the label
This commit is contained in:
parent
0f59b3c96b
commit
45d9a113c3
1 changed files with 4 additions and 0 deletions
|
|
@ -95,6 +95,10 @@ const trendingStatusesController: AppController = async (c) => {
|
||||||
const events = await store.query([{ ids }])
|
const events = await store.query([{ ids }])
|
||||||
.then((events) => hydrateEvents({ events, store }));
|
.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(
|
const statuses = await Promise.all(
|
||||||
events.map((event) => renderStatus(event, {})),
|
events.map((event) => renderStatus(event, {})),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue