feat: Sort Nostr chat messages by timestamp for chronological display

- Update the computed property in ChatComponent to sort messages by their creation timestamp, ensuring they are displayed in chronological order for better user experience.
This commit is contained in:
padreug 2025-08-10 17:23:18 +02:00
parent de918419fa
commit 22b3c430fa

View file

@ -421,7 +421,10 @@ const {
// Computed // Computed
const currentMessages = computed(() => { const currentMessages = computed(() => {
if (!selectedPeer.value) return [] if (!selectedPeer.value) return []
return messages.value.get(selectedPeer.value.pubkey) || [] const peerMessages = messages.value.get(selectedPeer.value.pubkey) || []
// Sort messages by timestamp (oldest first) to ensure chronological order
return [...peerMessages].sort((a, b) => a.created_at - b.created_at)
}) })
// Sort peers by latest message timestamp (newest first) and unread status // Sort peers by latest message timestamp (newest first) and unread status