Skip to content

Commit

Permalink
Move new older-than params to front of the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
rottabonus committed May 10, 2024
1 parent 46f2cb2 commit b3d0264
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/api/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export const getOlderThanParamsIfHasUnread =
(buddyId: string): Array<PollingParams> => {
console.log('getOlderThanParamsIfHasUnread for buddyId:', buddyId);
const buddyMessages = messages[buddyId] ?? {};

const sorted = Object.keys(buddyMessages).map(
msgId => buddyMessages[msgId],
);
Expand Down
3 changes: 2 additions & 1 deletion src/state/reducers/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const reducer: automaton.Reducer<State, actions.Action> = (
// 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,
Expand Down Expand Up @@ -132,7 +133,7 @@ export const reducer: automaton.Reducer<State, actions.Action> = (
messages: RD.success(nextMessages),
previousMsgId,
currentParams: nextCurrent,
pollingQueue: [...nextQueue, ...newOlderThanParams],
pollingQueue: [...newOlderThanParams, ...nextQueue],
},
nextCmd,
);
Expand Down

0 comments on commit b3d0264

Please sign in to comment.