sort notes

This commit is contained in:
k00b 2025-03-06 15:21:50 -06:00
parent 9292d4f991
commit b7130b68fd

View File

@ -405,9 +405,12 @@ async function getNotesWithLinks (userPubkeys, timeIntervalHours, relayUrls, ign
* @returns {String} - Formatted string with note information
*/
function formatNoteOutput (notes) {
// Sort notes by timestamp (newest first)
const sortedNotes = [...notes].sort((a, b) => b.created_at - a.created_at)
const output = []
for (const note of notes) {
for (const note of sortedNotes) {
// Get note ID as npub
const noteId = nip19.noteEncode(note.id)
const pubkey = nip19.npubEncode(note.pubkey)