remove unread top banner on scroll to bottom

pull/1792/head
audric 4 years ago
parent 5f994851d1
commit dbf6a0183f

@ -6,6 +6,7 @@ import _ from 'lodash';
import { contextMenu } from 'react-contexify'; import { contextMenu } from 'react-contexify';
import { import {
fetchMessagesForConversation, fetchMessagesForConversation,
markConversationFullyRead,
quotedMessageToAnimate, quotedMessageToAnimate,
ReduxConversationType, ReduxConversationType,
setNextMessageToPlay, setNextMessageToPlay,
@ -173,7 +174,9 @@ class SessionMessagesListContainerInner extends React.Component<Props> {
} }
if ((forceIsOnBottom || this.getScrollOffsetBottomPx() === 0) && isElectronWindowFocused()) { 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); const conversation = getConversationController().get(conversationKey);
if (isElectronWindowFocused()) { if (isElectronWindowFocused()) {
void conversation.markRead(messagesProps[0].propsForMessage.receivedAt || 0); void conversation.markRead(messagesProps[0].propsForMessage.receivedAt || 0).then(() => {
window.inboxStore?.dispatch(markConversationFullyRead(conversationKey));
});
} }
} }

@ -601,6 +601,17 @@ const conversationsSlice = createSlice({
return handleConversationReset(state, action); return handleConversationReset(state, action);
}, },
markConversationFullyRead(state: ConversationsStateType, action: PayloadAction<string>) {
if (state.selectedConversation !== action.payload) {
return state;
}
return {
...state,
firstUnreadMessageId: undefined,
};
},
openConversationExternal( openConversationExternal(
state: ConversationsStateType, state: ConversationsStateType,
action: PayloadAction<{ action: PayloadAction<{
@ -711,6 +722,7 @@ export const {
messageChanged, messageChanged,
messagesChanged, messagesChanged,
openConversationExternal, openConversationExternal,
markConversationFullyRead,
// layout stuff // layout stuff
showMessageDetailsView, showMessageDetailsView,
closeMessageDetailsView, closeMessageDetailsView,

Loading…
Cancel
Save