Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid notifications while joining #2660

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions frontend/model/notifications/messageReceivePostEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ async function messageReceivePostEffect ({

const chatNotificationSettings = rootGetters.chatNotificationSettings[contractID] || rootGetters.chatNotificationSettings.default
const { messageNotification, messageSound } = chatNotificationSettings

// If the contract is syncing (meaning we're loading the app, joining a
// chatroom, etc.), don't use a native notification or sound. Do this only
// for messages coming over the WS.
// This may not be 100% reliable, but `firstSync` should make it work in
// most cases.
const isSyncing = sbp('chelonia/contract/isSyncing', contractID, { firstSync: true })
// TODO: This could be an issue (false positive for emitting a native
// notification) when the initial sync gets interrupted (e.g., network issues)
// and then resumed.
// In this case, we may get sound notifications for old events that we
// should not, because technically it's not the first sync.
if (isSyncing) return

const shouldNotifyMessage = messageNotification === MESSAGE_NOTIFY_SETTINGS.ALL_MESSAGES ||
(messageNotification === MESSAGE_NOTIFY_SETTINGS.DIRECT_MESSAGES && isDMOrMention)
const shouldSoundMessage = messageSound === MESSAGE_NOTIFY_SETTINGS.ALL_MESSAGES ||
Expand Down