diff --git a/src/components/middle/MessageList.tsx b/src/components/middle/MessageList.tsx index 2cf4fd4d0..0428c904e 100644 --- a/src/components/middle/MessageList.tsx +++ b/src/components/middle/MessageList.tsx @@ -140,10 +140,8 @@ const MessageList: FC = ({ const anchorIdRef = useRef(); const anchorTopRef = useRef(); const listItemElementsRef = useRef(); - // Not updated (as we want the unread divider to keep its position) - const memoUnreadDividerBeforeIdRef = useRef(firstUnreadId); - // Updated every time (to be used from intersection callback closure) const memoFirstUnreadIdRef = useRef(); + const memoUnreadDividerBeforeIdRef = useRef(); const memoFocusingIdRef = useRef(); const isScrollTopJustUpdatedRef = useRef(false); const shouldAnimateAppearanceRef = useRef(Boolean(lastMessage)); @@ -161,10 +159,18 @@ const MessageList: FC = ({ } }, [areMessagesLoaded]); + // Updated every time (to be used from intersection callback closure) useOnChange(() => { memoFirstUnreadIdRef.current = firstUnreadId; }, [firstUnreadId]); + // Updated only once when messages are loaded (as we want the unread divider to keep its position) + useOnChange(() => { + if (areMessagesLoaded) { + memoUnreadDividerBeforeIdRef.current = memoFirstUnreadIdRef.current; + } + }, [areMessagesLoaded]); + useOnChange(() => { memoFocusingIdRef.current = focusingId; }, [focusingId]); diff --git a/src/modules/actions/api/messages.ts b/src/modules/actions/api/messages.ts index ee07af2bf..a5820051b 100644 --- a/src/modules/actions/api/messages.ts +++ b/src/modules/actions/api/messages.ts @@ -57,7 +57,7 @@ import { IS_IOS } from '../../../util/environment'; const uploadProgressCallbacks = new Map(); -const runDebouncedForMarkRead = debounce((cb) => cb(), 1000, false); +const runDebouncedForMarkRead = debounce((cb) => cb(), 500, false); addReducer('loadViewportMessages', (global, actions, payload) => { const { diff --git a/src/modules/actions/apiUpdaters/chats.ts b/src/modules/actions/apiUpdaters/chats.ts index 09ea73a6c..c76f826d0 100644 --- a/src/modules/actions/apiUpdaters/chats.ts +++ b/src/modules/actions/apiUpdaters/chats.ts @@ -26,7 +26,7 @@ import { throttle } from '../../../util/schedulers'; const TYPING_STATUS_CLEAR_DELAY = 6000; // 6 seconds // Enough to animate and mark as read in Message List -const CURRENT_CHAT_UNREAD_DELAY = 1000; +const CURRENT_CHAT_UNREAD_DELAY = 1500; const runThrottledForUpdateAppBadge = throttle((cb) => cb(), CURRENT_CHAT_UNREAD_DELAY, true); addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {