From dbf6a0183f2c63e9b5bb776ce4d4d68e697fa355 Mon Sep 17 00:00:00 2001 From: audric Date: Mon, 26 Jul 2021 11:30:53 +1000 Subject: [PATCH] remove unread top banner on scroll to bottom --- .../conversation/SessionMessagesListContainer.tsx | 9 +++++++-- ts/state/ducks/conversations.ts | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ts/components/session/conversation/SessionMessagesListContainer.tsx b/ts/components/session/conversation/SessionMessagesListContainer.tsx index c7514d497..81adf29d3 100644 --- a/ts/components/session/conversation/SessionMessagesListContainer.tsx +++ b/ts/components/session/conversation/SessionMessagesListContainer.tsx @@ -6,6 +6,7 @@ import _ from 'lodash'; import { contextMenu } from 'react-contexify'; import { fetchMessagesForConversation, + markConversationFullyRead, quotedMessageToAnimate, ReduxConversationType, setNextMessageToPlay, @@ -173,7 +174,9 @@ class SessionMessagesListContainerInner extends React.Component { } if ((forceIsOnBottom || this.getScrollOffsetBottomPx() === 0) && isElectronWindowFocused()) { - void conversation.markRead(messagesProps[0].propsForMessage.receivedAt || 0); + void conversation.markRead(messagesProps[0].propsForMessage.receivedAt || 0).then(() => { + window.inboxStore?.dispatch(markConversationFullyRead(conversationKey)); + }); } } @@ -369,7 +372,9 @@ class SessionMessagesListContainerInner extends React.Component { const conversation = getConversationController().get(conversationKey); if (isElectronWindowFocused()) { - void conversation.markRead(messagesProps[0].propsForMessage.receivedAt || 0); + void conversation.markRead(messagesProps[0].propsForMessage.receivedAt || 0).then(() => { + window.inboxStore?.dispatch(markConversationFullyRead(conversationKey)); + }); } } diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index af5c3d219..0940c65b2 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -601,6 +601,17 @@ const conversationsSlice = createSlice({ return handleConversationReset(state, action); }, + markConversationFullyRead(state: ConversationsStateType, action: PayloadAction) { + if (state.selectedConversation !== action.payload) { + return state; + } + + return { + ...state, + firstUnreadMessageId: undefined, + }; + }, + openConversationExternal( state: ConversationsStateType, action: PayloadAction<{ @@ -711,6 +722,7 @@ export const { messageChanged, messagesChanged, openConversationExternal, + markConversationFullyRead, // layout stuff showMessageDetailsView, closeMessageDetailsView,