Open aperezdc opened 7 years ago
@jaragunde: I am afraid that you are right, and WebKitNotification does not include a field to expose the tag being passed to the WebKitGTK+ API by the web application. Having Riot assign a tag to the notification that contained the room identifier would be just perfect.
I wonder if we should withdraw all notifications when the Revolt window is focused. Some apps, like Whatsapp on Android, work like that. When you are in the Revolt window you can always see the badges that inform you about the new messages or mentions...
@jaragunde: That is actually a good idea, and it is something we can implement already. We just need to keep around a set()
of the identifiers of notifications send while unfocused, and call g_application_withdraw_notification()
on them when we gain focus back. I can have a patch done for that.
I have pushed https://github.com/aperezdc/revolt/commit/c8babea83894dc51024ce3de3afdc567eed52d78 implementing @jaragunde's suggestion of withdrawing all the emitted notifications when focus is regained, and pushed a new built to the master
version in the Flatpak repository.
In a slightly related note, can you do some kind of JS injection to switch rooms when the associated notification is clicked?
I think we may be able to do something not too hacky by hooking into the platform abstraction code added recently in the develop
branch of Riot.
BTW, I have filed a bug asking to have the .tag
attribute of web notifications exposed in the WebKitGTK+ API, which would also help with this issue.
(Originally reported by @jaragunde.)
The expected behavior for chat applications is to make the notification related to a certain conversation disappear when that conversation is opened in the client.
We currently cannot do that; we can detect when a certain room is opened by means of subscribing to the notify::uri signal. The URI changes when a certain conversation is clicked, and we can extract its id from the URI. Unfortunately, there is no way to relate the room id with the corresponding notification: notifications only come with an autonumeric id, a title (which we use to discriminate conversations) and some contents.
We may be able to improve the situation if we took a look at the code of the Riot web client and made sure they are using the notification tag field to reuse notifications. This is a worthy improvement in any case, to the room id as the tag in the web notification so notifications can be reused:
https://developer.mozilla.org/en-US/docs/Web/API/Notification/tag
When this is done, we need to check again if it's possible to access that tag in the client. If we cannot, we might need new API in WebKitGTK+...
This could get a bit tricky :D