diff --git a/src/api/messages.ts b/src/api/messages.ts index b87a36f2..74663df1 100644 --- a/src/api/messages.ts +++ b/src/api/messages.ts @@ -230,6 +230,7 @@ export const getOlderThanParamsIfHasUnread = (buddyId: string): Array => { console.log('getOlderThanParamsIfHasUnread for buddyId:', buddyId); const buddyMessages = messages[buddyId] ?? {}; + const sorted = Object.keys(buddyMessages).map( msgId => buddyMessages[msgId], ); diff --git a/src/state/reducers/messages.ts b/src/state/reducers/messages.ts index 733b0005..826f9dd4 100644 --- a/src/state/reducers/messages.ts +++ b/src/state/reducers/messages.ts @@ -103,6 +103,7 @@ export const reducer: automaton.Reducer = ( // case 2: marking unread message // case 3: marking unread only for messages that are seen 100% console.log('got messages', newMessages); + const newOlderThanParams = messageApi.getParamsForUnreadMessages( newMessages, state.currentParams, @@ -132,7 +133,7 @@ export const reducer: automaton.Reducer = ( messages: RD.success(nextMessages), previousMsgId, currentParams: nextCurrent, - pollingQueue: [...nextQueue, ...newOlderThanParams], + pollingQueue: [...newOlderThanParams, ...nextQueue], }, nextCmd, );