Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ fetchFormerMessagesを日付昇順にしてfetchLatterMessagesに合わせる #4280

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading