diff --git a/frontend/controller/actions/chatroom.js b/frontend/controller/actions/chatroom.js index 17cc6503c3..0280e2dcb8 100644 --- a/frontend/controller/actions/chatroom.js +++ b/frontend/controller/actions/chatroom.js @@ -24,9 +24,6 @@ sbp('okTurtles.events/on', MESSAGE_RECEIVE_RAW, ({ const getters = sbp('state/vuex/getters') const rootState = sbp('state/vuex/state') const targetChatroomState = rootState[contractID] - const currentRoute = sbp('controller/router').history.current || '' - const isTargetChatroomCurrentlyActive = currentRoute.path.includes('/group-chat') && - getters.currentChatRoomId === contractID // when the target chatroom is currently open/active on the browser, No need to send a notification. const mentions = makeMentionFromUserID(getters.ourIdentityContractId) const msgData = newMessage || data const isMentionedMe = (!!newMessage || data.type === MESSAGE_TYPES.TEXT) && msgData.text && @@ -42,7 +39,7 @@ sbp('okTurtles.events/on', MESSAGE_RECEIVE_RAW, ({ if (isAlreadyAdded) return } - !isTargetChatroomCurrentlyActive && messageReceivePostEffect({ + messageReceivePostEffect({ contractID, messageHash: msgData.hash, height: msgData.height, diff --git a/frontend/model/notifications/messageReceivePostEffect.js b/frontend/model/notifications/messageReceivePostEffect.js index 64fd5ecf56..e9af2e9543 100644 --- a/frontend/model/notifications/messageReceivePostEffect.js +++ b/frontend/model/notifications/messageReceivePostEffect.js @@ -35,6 +35,13 @@ async function messageReceivePostEffect ({ sbp('gi.actions/identity/kv/addChatRoomUnreadMessage', { contractID, messageHash, createdHeight: height }) } + // TODO: This needs to be done differently in the SW + const currentRoute = sbp('controller/router').history.current || '' + const isTargetChatroomCurrentlyActive = currentRoute.path.includes('/group-chat') && + rootGetters.currentChatRoomId === contractID // when the target chatroom is currently open/active on the browser, No need to send a notification. + if (isTargetChatroomCurrentlyActive) return // Skip notifications + // END TODO: This needs to be done differently in the SW + let title = `# ${chatRoomName}` let icon if (isGroupDM) {