WIP: refactor client to use native Notifications API #219

Closed
Johann150 wants to merge 2 commits from refactor/notifications into main
Owner

Taking this as a starting point from @Michcio 's work. I think there are still some things to be fixed:

  • notification type "app" is not handled at all
  • notifications are not being marked as read (removed in 5d9bc2553b)
    If a notifications widget is also present that may mark notifications as read, but if not notifications will be shown and not marked as read.
  • general clean up (e.g. remove unused notification-toast.vue component, use i18n)

Also I'm not sure what happens if you were to return to Foundkey and have a bunch of unread notifications. Would your phone explode with notifications? In that case we might want to e.g. not send notifications through the native API that are older than some threshold, and instead only show them in the notifications widget.

Taking this as a starting point from @Michcio 's work. I think there are still some things to be fixed: - [ ] notification type "app" is not handled at all - [ ] notifications are not being marked as read (removed in 5d9bc2553bc10308a588ecd3a8cde10bd9803bf9) If a notifications widget is also present that may mark notifications as read, but if not notifications will be shown and not marked as read. - [ ] general clean up (e.g. remove unused `notification-toast.vue` component, use i18n) Also I'm not sure what happens if you were to return to Foundkey and have a bunch of unread notifications. Would your phone explode with notifications? In that case we might want to e.g. not send notifications through the native API that are older than some threshold, and instead only show them in the notifications widget.
Johann150 added 2 commits 2022-10-31 09:30:31 +00:00
Icons don't work in Safari just because they don't lmao

This is just barely tested, bear with me
Send notifications also when the tab is not visible
Some checks failed
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed
5d9bc2553b
Johann150 added this to the (deleted) project 2022-10-31 09:30:38 +00:00
Contributor

Also I'm not sure what happens if you were to return to Foundkey and have a bunch of unread notifications. Would your phone explode with notifications?

I use this on my instance, and, there's a small problem, you are getting notifications on only one device, and so that device is a phone in my case, you are also getting misskey sounds on pc, but notifications are going to phone for some reason unknown to me

> Also I'm not sure what happens if you were to return to Foundkey and have a bunch of unread notifications. Would your phone explode with notifications? I use this on my instance, and, there's a small problem, you are getting notifications on only one device, and so that device is a phone in my case, you are also getting misskey sounds on pc, but notifications are going to phone for some reason unknown to me
Contributor

Some notes from me:

I believe the requestPermission call is broken right now because at least Safari demands that it must only be called in direct result of user action.

Idk where's Jeder's problem coming from, sorry.

Idk what notification type "app" is which is why this rapidly thrown together code ignores it.

I specifically didn't want to mark notifications as read because it annoys me af when UI decides that oh you've seen it because you were on the page and then I only actually see it hours later by accident.

re: coming back and exploding. I don't think it would happen because this ties into a notification stream which only processes notifs as they come in?

Also I remember my assignment of images to Notification attributes freaked Jeder out initially. I didn't notice it could sometimes produce a huge anime girl on your screen because Safari ignores images completely.

Some notes from me: I believe the requestPermission call is broken right now because at least Safari demands that it must only be called in direct result of user action. Idk where's Jeder's problem coming from, sorry. Idk what notification type "app" is which is why this rapidly thrown together code ignores it. I specifically didn't want to mark notifications as read because it annoys me af when UI decides that oh you've seen it because you were on the page and then I only actually see it hours later by accident. re: coming back and exploding. I don't think it would happen because this ties into a notification stream which only processes notifs as they come in? Also I remember my assignment of images to Notification attributes freaked Jeder out initially. I didn't notice it could sometimes produce a huge anime girl on your screen because Safari ignores images completely.
Author
Owner

I believe the requestPermission call is broken right now because at least Safari demands that it must only be called in direct result of user action.

I've been seeing this error in the Firefox dev console for a while:

The Notification permission may only be requested from inside a short running user-generated event handler.


Idk what notification type "app" is [...]

Apps can create custom notifications via the API endpoint notifications/create.

I specifically didn't want to mark notifications as read because it annoys me af when UI decides that oh you've seen it because you were on the page and then I only actually see it hours later by accident.

Okay understandable with the way Firefox shows a notification (fades out after some time). But might be a different story on mobile, if it displayed like normal notifications that you have to swipe away? (No idea if that is actually how it works.)

> I believe the requestPermission call is broken right now because at least Safari demands that it must only be called in direct result of user action. I've been seeing this error in the Firefox dev console for a while: > The Notification permission may only be requested from inside a short running user-generated event handler. - - - > Idk what notification type "app" is [...] Apps can create custom notifications via the API endpoint `notifications/create`. > I specifically didn't want to mark notifications as read because it annoys me af when UI decides that oh you've seen it because you were on the page and then I only actually see it hours later by accident. Okay understandable with the way Firefox shows a notification (fades out after some time). But might be a different story on mobile, if it displayed like normal notifications that you have to swipe away? (No idea if that is actually how it works.)
Contributor

I think there may be a separate event on a Notification object on it being dismissed, I didn't get to figuring it out though

I think there may be a separate event on a Notification object on it being dismissed, I didn't get to figuring it out though
Contributor

Okay understandable with the way Firefox shows a notification (fades out after some time). But might be a different story on mobile, if it displayed like normal notifications that you have to swipe away? (No idea if that is actually how it works.)

On Windows, Android, and probably any other os with a notification drawer, those notifications show up for few seconds, and then go to that drawer, waiting for you to dismiss them

> Okay understandable with the way Firefox shows a notification (fades out after some time). But might be a different story on mobile, if it displayed like normal notifications that you have to swipe away? (No idea if that is actually how it works.) On Windows, Android, and probably any other os with a notification drawer, those notifications show up for few seconds, and then go to that drawer, waiting for you to dismiss them
Author
Owner

Should have thought of this earlier, but the service worker basically already has all this implemented in the push notification handler.

So instead of reimplementing this, the thing to fix is: If the instance does not have push notifications enabled, get the notification data into the service worker.

I think it makes more sense to start over since the modifications here are unnecessary then.

Should have thought of this earlier, but the service worker basically already has all this implemented in the push notification handler. So instead of reimplementing this, the thing to fix is: If the instance does not have push notifications enabled, get the notification data into the service worker. I think it makes more sense to start over since the modifications here are unnecessary then.
Johann150 closed this pull request 2022-11-12 16:40:55 +00:00
Johann150 deleted branch refactor/notifications 2022-11-12 16:41:44 +00:00
Johann150 removed this from the (deleted) project 2022-11-12 20:23:47 +00:00
Some checks failed
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
feature
fix
upkeep
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: FoundKeyGang/FoundKey#219
No description provided.