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

Dismiss notifications on read #705

Merged
merged 2 commits into from
Jan 10, 2025
Merged

Dismiss notifications on read #705

merged 2 commits into from
Jan 10, 2025

Conversation

jocmp
Copy link
Owner

@jocmp jocmp commented Jan 9, 2025

wip

Verified

This commit was signed with the committer’s verified signature.
jocmp Josiah Campbell
@sandboiii
Copy link

Hey, I really wanted to clear notifications on read and made the following simple implementation:
sandboiii@fb34b46

Does it really necessary to store all the information of notifications in db? Looks like a bit of over-engineering to me

@jocmp jocmp changed the title Clear notifications on read Dismiss notifications on read Jan 9, 2025
@jocmp jocmp force-pushed the jc/hide-notifications branch from bcf4ca5 to b0a9116 Compare January 9, 2025 14:33
@jocmp
Copy link
Owner Author

jocmp commented Jan 9, 2025

@sandboiii hey! I hear you about the over-engineering. My first implementation was about the same that you had. The problem is the group notification, the one that bundles all the article notifications together. The group notification appear as an empty stub after you clear the last article which looks bad.

Based on this old danlew post I decided to track these in a DB. That way when all notifications are clear the group notification can also be dismissed.

https://github.com/jocmp/capyreader/pull/705/files#diff-07abb723eee2da7a6c31ed4828d50fee0ed36067bb57f22a7c53fa2604628193R54-R56

There's another API that tracks this called getActiveNotifications, but that doesn't work either since it can report the wrong notification amount if all articles are dismissed simultaneously.

@sandboiii
Copy link

it can report the wrong notification amount

Really? How do you know this?

@jocmp
Copy link
Owner Author

jocmp commented Jan 9, 2025

I noticed it while testing 10+ notifications. Plus the API does not guarantee that the activeNotifications will be updated immediately.

So take the following example

notificationIDs.forEach { // assume 3 notifications
  notificationManager.cancel(it)
}

print(notificationManager.activeNotifications.size)

what I noticed was the following - sometimes the notification size was immediately updated, sometimes the delay meant the size was still a number ranging from 1 to the max. In any case, the size isn't guaranteed to be 0 after the last cancel.

cancel
cancel 
cancel

size // #=> any number from 0 to 3

@jocmp jocmp marked this pull request as ready for review January 10, 2025 01:59

Verified

This commit was signed with the committer’s verified signature.
jocmp Josiah Campbell
@jocmp jocmp force-pushed the jc/hide-notifications branch from b0a9116 to ec8b79c Compare January 10, 2025 02:28
@jocmp jocmp merged commit 45692e2 into main Jan 10, 2025
1 check passed
@jocmp jocmp deleted the jc/hide-notifications branch January 10, 2025 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants