diff --git a/src/components/Main/MainView/ChannelView/ChannelViewContent/composables/useChannelMessageFetcher.ts b/src/components/Main/MainView/ChannelView/ChannelViewContent/composables/useChannelMessageFetcher.ts index 40ced9be4..b01c23d1a 100644 --- a/src/components/Main/MainView/ChannelView/ChannelViewContent/composables/useChannelMessageFetcher.ts +++ b/src/components/Main/MainView/ChannelView/ChannelViewContent/composables/useChannelMessageFetcher.ts @@ -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 ): Promise => { await waitHeightResolved - const { messages, hasMore } = await fetchMessagesByChannelId({ + const { messages: messagesAsc, hasMore } = await fetchMessagesByChannelId({ channelId: props.channelId, limit: fetchLimit.value, order: 'asc', @@ -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 ( @@ -146,11 +147,7 @@ const useChannelMessageFetcher = ( fetchLatterMessages(isReachedLatest) ]) return [ - ...new Set([ - ...formerMessageIds.reverse(), - entryMessage.id, - ...latterMessageIds - ]) + ...new Set([...formerMessageIds, entryMessage.id, ...latterMessageIds]) ] } diff --git a/src/components/Main/MainView/MessagesScroller/composables/useMessagesFetcher.ts b/src/components/Main/MainView/MessagesScroller/composables/useMessagesFetcher.ts index 0a3ee9a5f..3cad0bbc4 100644 --- a/src/components/Main/MainView/MessagesScroller/composables/useMessagesFetcher.ts +++ b/src/components/Main/MainView/MessagesScroller/composables/useMessagesFetcher.ts @@ -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])] } ) }