Skip to content
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

fix(browser): Don't create web notifications for old notifications #1943

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

nickvergessen
Copy link
Member

Sometimes a notification got "newly mounted" while being old. This can happen when a user has many notifications (100-1). The UI first only loads (100-76), if any notification is then resolved (e.g. by deleting or reading a chat), further old notifications (75+74) would be added to the UI and triggered a web notification (including call sound) in the past.

This threshold ID is therefore updated to only higher values, before each pulling of notifications to ensure that we only ever web-notify on new notifications and not newly loaded old notifications.

Sometimes a notification got "newly mounted" while being old.
This can happen when a user has many notifications (100-1).
The UI first only loads (100-76), if any notification is then
resolved (e.g. by deleting or reading a chat), further old
notifications (75+74) would be added to the UI and triggered
a web notification (including call sound) in the past.

This threshold ID is therefore updated to only higher values,
before each pulling of notifications to ensure that we only ever
web-notify on new notifications and not newly loaded old
notifications.

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member Author

/compile /

@nickvergessen
Copy link
Member Author

/backport 6a54367 to stable29

@nickvergessen
Copy link
Member Author

/backport 6a54367 to stable28

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
if (this.shouldNotify && this.$parent.$parent.$parent.showBrowserNotifications) {
if (this.shouldNotify
&& this.$parent.$parent.$parent.showBrowserNotifications
&& this.$parent.$parent.$parent.webNotificationsThresholdId < this.notificationId) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good in general. I'm just not sure about this place:

  • you changing webNotificationsThresholdId before and right after the _fetch, so Vue components for new notifications might not be mounted yet. Wouldn't we skip this block of code for the very last notification?
Suggested change
&& this.$parent.$parent.$parent.webNotificationsThresholdId < this.notificationId) {
&& this.$parent.$parent.$parent.webNotificationsThresholdId <= this.notificationId) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you changing webNotificationsThresholdId before and right after the _fetch, so Vue components for new notifications might not be mounted yet.

Before was added "later" and should not be an issue.

After is no problem as the first run (!this.backgroundFetching which is wrapping it) is not generating notifications anyway. I was just afraid to remove this, in case someone would manually delete/resolve all of the initial load. Then the first background fetch would have an empty notification list and therefore there would still be sound+notifications for old things that are loaded with the first background fetch

@nickvergessen nickvergessen merged commit d6ce0dc into master Jun 10, 2024
37 checks passed
@nickvergessen nickvergessen deleted the bugfix/noid/no-notification-for-past branch June 10, 2024 12:36
@nickvergessen
Copy link
Member Author

/backport 6a54367 to stable27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants