Skip to content

Commit

Permalink
🐛 fetchNewMessages: fetch latest messages created_at asc
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0q committed Sep 7, 2024
1 parent 4232ebd commit eeaac87
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,24 @@ const useChannelMessageFetcher = (
]
}

// 最新メッセージを作成日時昇順で取得
const fetchNewMessages = async (isReachedLatest: Ref<boolean>) => {
await waitHeightResolved
const { messages, hasMore } = await fetchMessagesByChannelId({
channelId: props.channelId,
limit: fetchLimit.value,
order: 'asc',
order: 'desc',
since: loadedMessageLatestDate.value
})

if (!hasMore) {
isReachedLatest.value = true
}

updateDates(messages)
const messagesAsc = messages.reverse()
updateDates(messagesAsc)

return messages.map(message => message.id)
return messagesAsc.map(message => message.id)
}

const onReachedLatest = async () => {
Expand Down

0 comments on commit eeaac87

Please sign in to comment.