When the webapp is focused, we make a call to mark the current channel as read. When a notification is clicked, we make a call to both focus the window and navigate to the new route if needed. This introduces a race condition in which the channel the user was on before switching to the one where the notification was triggered from would be marked read instead, causing the perception that an unread was missed.
This doesn't really happen much on the web side, as the calls are all run as part of a single thread and the push() action will likely update the currentChannel value before the focus handle can get in the way, but on Desktop App the focus action is called much earlier and done as a result of Electron telling the renderer process to focus. Then afterwards an IPC messages takes care of the routing.
This PR waits for the navigation callback from the webapp before focusing the application ensuring that the webapp will have switched to the new location before the focus trigger happens.
Summary
When the webapp is focused, we make a call to mark the current channel as read. When a notification is clicked, we make a call to both focus the window and navigate to the new route if needed. This introduces a race condition in which the channel the user was on before switching to the one where the notification was triggered from would be marked read instead, causing the perception that an unread was missed.
This doesn't really happen much on the web side, as the calls are all run as part of a single thread and the
push()
action will likely update thecurrentChannel
value before the focus handle can get in the way, but on Desktop App the focus action is called much earlier and done as a result of Electron telling the renderer process to focus. Then afterwards an IPC messages takes care of the routing.This PR waits for the navigation callback from the webapp before focusing the application ensuring that the webapp will have switched to the new location before the focus trigger happens.
Ticket Link
https://mattermost.atlassian.net/browse/MM-46634