Skip to content

Commit

Permalink
Merge pull request #4279 from traPtitech/fix/messages-order
Browse files Browse the repository at this point in the history
fetchNewMessagesが最古のN件を取得している問題の修正
  • Loading branch information
ras0q authored Sep 8, 2024
2 parents 4232ebd + 30df6ed commit 8bb76c7
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 8bb76c7

Please sign in to comment.