trendingStatusesController: sort events in the order they appear in the label
This commit is contained in:
parent
0f59b3c96b
commit
45d9a113c3
|
@ -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…
Reference in New Issue