accountStatusesController: sort results by timestamp

This commit is contained in:
Alex Gleason 2023-05-03 15:33:54 -05:00
parent 502af2cd48
commit 3880fdd61c
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 2 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import { type AppController } from '@/app.ts';
import { nip05, z } from '@/deps.ts';
import { getAuthor, getFilter } from '@/client.ts';
import { toAccount, toStatus } from '@/transmute.ts';
import { bech32ToPubkey } from '@/utils.ts';
import { bech32ToPubkey, eventDateComparator } from '@/utils.ts';
import type { Event } from '@/event.ts';
@ -97,7 +97,7 @@ const accountStatusesController: AppController = async (c) => {
return c.json([]);
}
const events = await getFilter({ authors: [pubkey], kinds: [1], limit });
const events = (await getFilter({ authors: [pubkey], kinds: [1], limit })).sort(eventDateComparator);
const statuses = await Promise.all(events.map((event) => toStatus(event)));
return c.json(statuses);