Skip to content

Commit

Permalink
Move active chatroom test (#2399)
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat authored Oct 28, 2024
1 parent f8ec52b commit b98eb74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 1 addition & 4 deletions frontend/controller/actions/chatroom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -42,7 +39,7 @@ sbp('okTurtles.events/on', MESSAGE_RECEIVE_RAW, ({
if (isAlreadyAdded) return
}

!isTargetChatroomCurrentlyActive && messageReceivePostEffect({
messageReceivePostEffect({
contractID,
messageHash: msgData.hash,
height: msgData.height,
Expand Down
7 changes: 7 additions & 0 deletions frontend/model/notifications/messageReceivePostEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b98eb74

Please sign in to comment.