-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add support for desktop notifications #192
Conversation
7109b24
to
b62815a
Compare
Wow, nice work! Maybe worth telling about |
@paulcarroty I put it in docs/iamb.5.md, is there somewhere else where I should add it? |
@ulyssa do you have some idea how I could get on about detecting if a room/dm is currently "open", to skip showing a notification in that case? I suppose that the notification handler should only have access to BTW, it seems like |
a1d483a
to
507b0b0
Compare
It looks like it's missing a
There's not a great way to get this from outside the
I think I like the second option the most. I've been taking a look at what handling intentional mentions could look like, and I think a similar processing mechanism could be used there. I'll try to implement this along with the current window checking, and then you can use that for notifications. |
src/config.rs
Outdated
@@ -476,6 +476,7 @@ pub struct TunableValues { | |||
pub message_user_color: bool, | |||
pub default_room: Option<String>, | |||
pub open_command: Option<Vec<String>>, | |||
pub notifications: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this a String instead that can be set to "all"
or "none"
? That way it can be configurable to other values in the future, like "mentions"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or rather, a string in the config.json
, but an enum that derives Deserialize
here.
In Element.io, notifications are very fine-grained: This then gets "multiplied" with per-chat settings, which only offer a few settings: I have to investigate a bit more. I don't know if these settings are private to the client or shared with the server. It would make sense to have the server only send out necessary notifications per each client, that will actually be used. Looking at the matrix sdk, I don't fully understand what state goes where. At a glance, it looks like it does save some state to the homeserver. In our pub struct Notifications {
pub one_to_one: NotificationProcessing,
pub group_chats: NotificationProcessing,
// TODO: separate displayname, username, @room, and keywords.
pub mentions: NotificationProcessing,
// TODO: invitations, call-invitation, bots, and room-upgrades.
}
pub enum NotificationProcessing {
#[default]
Off,
On,
Noisy, // Not sure, it's in element.io, probably means to stop after N amount of unacknowledged notifications.
} |
Regarding option 1 or 2, my first instinct is against processing / showing notifications in the draw-loop. I now realize that the step and render can be independent, never mind the above. In the PR I tried for option 1 because that was easier. |
e09eab4
to
09ea5ad
Compare
I found out that the notification settings matrix of the screenshots can be retrieved and set with the SDK, which makes a lot of sense so that the user doesn't have to manually copy it over to each client. The client basically only needs one "enable in this session" toggle. We could later add commands to set or display those settings, but for now I think it's quite okay to leave it out. I had to add a check that the notification-timestamp is greater than the app-startup-timestamp, because I am getting a barrage of past notifications. I'm not sure how a push notification is supposed to be "marked as read", perhaps we need to send a read-receipt. The >100 characters check is also somewhat primitive. If the body contains a quote / is a reply, that should also be stripped out. |
d93315a
to
4d44b8c
Compare
Yep, I agree with this. Getting notifications enabled is the first step, and eventually there can be I noticed that the CI build failed on Windows. I've put up a fix for that in #221, and verified that it builds and notifications show up on Windows. (Although I'm not sure whether anyone is using iamb on Windows, since it looks like keyboard input got screwy after either a crossterm change or a Windows Terminal change, #220). If you pull in Having tried the PR out locally, I think it's ready to merge. It looks like the manual page will need to be updated to account for |
8b422bd
to
eb8fc49
Compare
Basic notifications feature.
eb8fc49
to
0577cab
Compare
@ulyssa thank you for fixing that! I think it's good to merge now. I updated the manual page. The barrage of past notifications is gone, it seems like the SDK itself takes care of marking as delivered. I only see notifications that have never been delivered to this client / push-session. I am still leaving in the line that discard notifications that are from before startup_time, but we could make that configurable later on. |
Basic notifications feature.
Can be enabled in config.json, disabled by default.