Commit ec938e2
Evie Gauthier
fix(notifications): suppress OS notification when app is focused; wrap in try/catch
Two bugs caused in-app notifications to silently vanish on desktop when
the window was focused:
1. window.Notification() was called unconditionally even when the window
had focus. In some browsers/environments (certain Chrome versions,
Electron, macOS DnD mode) calling the Notification constructor throws
or is silently rejected when the tab is active. Without a try/catch
the uncaught exception aborted the entire RoomEvent.Timeline handler
before setInAppBanner was ever reached — so neither the OS notification
NOR the in-app banner appeared. InviteNotifications already used
try/catch for the same reason; MessageNotifications did not.
2. The OS notification was semantically wrong when focused: the in-app
banner is the correct alert while the window is active. Added a
!document.hasFocus() guard to match the comment's stated intent
("alert when minimised or tab not active") and to prevent a duplicate
OS+in-app banner when another window is simply on top.
Mobile is unaffected: mobileOrTablet() already gates the OS block.
The in-app banner path (visibilityState === 'visible' → setInAppBanner)
is unchanged and continues to fire correctly on both desktop (focused)
and mobile (app visible in browser).1 parent fa01529 commit ec938e2
1 file changed
Lines changed: 47 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
357 | 372 | | |
358 | 373 | | |
359 | 374 | | |
| |||
0 commit comments