mattermost / desktop

Mattermost Desktop application for Windows, Mac and Linux
Apache License 2.0
2k stars 815 forks source link

[MM-46634] Force window to be focused after navigation on notification click #3051

Closed devinbinnie closed 4 months ago

devinbinnie commented 4 months ago

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 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.

Ticket Link

https://mattermost.atlassian.net/browse/MM-46634

Fixed an issue where clicking a notification would clear unreads for the wrong channel.
marianunez commented 4 months ago

Daniel is out this week so you may want to get another reviewer

devinbinnie commented 3 months ago

/cherry-pick release-5.8

mattermost-build commented 3 months ago

Cherry pick is scheduled.