remove unread top banner on scroll to bottom

This commit is contained in:
audric 2021-07-26 11:30:53 +10:00
parent 5f994851d1
commit dbf6a0183f
2 changed files with 19 additions and 2 deletions

View File

@ -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<Props> {
}
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<Props> {
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));
});
}
}

View File

@ -601,6 +601,17 @@ const conversationsSlice = createSlice({
return handleConversationReset(state, action);
},
markConversationFullyRead(state: ConversationsStateType, action: PayloadAction<string>) {
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,