Skip to content

Commit

Permalink
Merge pull request #4280 from traPtitech/refactor/return-messages-asc
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0q authored Oct 26, 2024
2 parents c0731fa + 32590ff commit 7bcaea7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,17 @@ const useChannelMessageFetcher = (
isReachedEnd.value = true
}

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

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

const fetchLatterMessages = async (
isReachedLatest: Ref<boolean>
): Promise<ChannelId[]> => {
await waitHeightResolved
const { messages, hasMore } = await fetchMessagesByChannelId({
const { messages: messagesAsc, hasMore } = await fetchMessagesByChannelId({
channelId: props.channelId,
limit: fetchLimit.value,
order: 'asc',
Expand All @@ -126,9 +127,9 @@ const useChannelMessageFetcher = (
isReachedLatest.value = true
}

updateDates(messages)
updateDates(messagesAsc)

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

const fetchAroundMessages = async (
Expand All @@ -146,11 +147,7 @@ const useChannelMessageFetcher = (
fetchLatterMessages(isReachedLatest)
])
return [
...new Set([
...formerMessageIds.reverse(),
entryMessage.id,
...latterMessageIds
])
...new Set([...formerMessageIds, entryMessage.id, ...latterMessageIds])
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ const useMessageFetcher = (
isLoading.value = false
isInitialLoad.value = false
lastLoadingDirection.value = 'former'
messageIds.value = [
...new Set([...newMessageIds.reverse(), ...messageIds.value])
]
messageIds.value = [...new Set([...newMessageIds, ...messageIds.value])]
}
)
}
Expand Down

0 comments on commit 7bcaea7

Please sign in to comment.