Skip to content

Commit 3518a51

Browse files
committed
fix "unread messages" indicator
1 parent 45c6f7f commit 3518a51

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/webchat/store/ui/ui-middleware.ts

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ShowChatScreenAction,
88
SetPageVisibleAction,
99
SetHasAcceptedTermsAction,
10+
SetOpenAction,
1011
} from "./ui-reducer";
1112
import { getStorage } from "../../helper/storage";
1213
import { setHasAcceptedTermsInStorage } from "../../helper/privacyPolicy";
@@ -17,6 +18,7 @@ export const uiMiddleware: Middleware<object, StoreState> =
1718
(
1819
action:
1920
| ToggleOpenAction
21+
| SetOpenAction
2022
| ShowChatScreenAction
2123
| SetPageVisibleAction
2224
| SetHasAcceptedTermsAction,
@@ -34,6 +36,21 @@ export const uiMiddleware: Middleware<object, StoreState> =
3436
break;
3537
}
3638

39+
case "SET_OPEN": {
40+
const open = action.open;
41+
42+
const { showHomeScreen, showPrevConversations, showChatOptionsScreen } =
43+
store.getState().ui;
44+
const isChatHistoryVisible =
45+
!showPrevConversations && !showChatOptionsScreen && !showHomeScreen;
46+
47+
if (open && isChatHistoryVisible) {
48+
store.dispatch(clearUnseenMessages());
49+
}
50+
51+
break;
52+
}
53+
3754
// if the chat screen is opened while the page is active, reset unread messages
3855
case "SHOW_CHAT_SCREEN": {
3956
if (store.getState().ui.isPageVisible) {

0 commit comments

Comments
 (0)