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

Use local read receipts for notifications #504

Merged
merged 6 commits into from
Dec 17, 2024

Conversation

ticruz38
Copy link
Collaborator

#500

Use a local store for read receipts, inspired by flotilla.

Copy link
Collaborator

@staab staab left a comment

Choose a reason for hiding this comment

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

Looks pretty good, although the notifications utilities should go in engine/notifications rather than domain (domain is purely for stateless utility functions related to nostr data types).

src/engine/state.ts Outdated Show resolved Hide resolved
@ticruz38 ticruz38 requested a review from staab December 13, 2024 13:32
Copy link
Collaborator

@staab staab left a comment

Choose a reason for hiding this comment

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

  • Various SEEN_ events are still being fetched and decrypted, we can remove all of that.
  • The subscriptions on the notifications pages aren't doing anything any more.
  • Record "mark all as seen" explicitly to avoid getting re-notified about old stuff. You'll need to check that when getting notifications for channels, which means you need to know which notification keys correspond to channels. So a different naming scheme than channel id might be needed.

src/app/state.ts Outdated Show resolved Hide resolved
onMount(() => {
const tracked = new Set()
setChecked(["replies", "mentions"])

const unsub = unreadMainNotifications.subscribe(async events => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is all dead code now

src/app/views/NotificationSectionReactions.svelte Outdated Show resolved Hide resolved
@@ -39,6 +39,8 @@
}
})

const markAllChannelsRead = () => setChecked($channels.map(c => c.id))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's do something here like channels/*, since old events frequently come in after marking all as read, resetting the notification bell. This is a flaw of the current approach.

@ticruz38
Copy link
Collaborator Author

  • Using a "channels/" prefix as a seen key for messages
  • seen all message is now dispatched as channels/* instead of a key for each channel.
  • Removed subscriptions in notifications onMount event
  • Set all read when logged in and signed up

@staab
Copy link
Collaborator

staab commented Dec 16, 2024

This can still be simplified a decent amount I think:

  • Since this is route based, setChecked can take a single key (like in flotilla). There's no need to differentiate between reactions/zaps for example, that was added for theoretical interoperability.
  • * should apply to all notifications, including channels, channels/* is a subset of that

@ticruz38
Copy link
Collaborator Author

applied your suggestions, path based seen check

Notifications are now under notes/* or reactions/, everything related to messages is under channels/, "*" is used for login and signup and is a fallback for any subpath no checked yet.

@staab staab merged commit 722d26e into coracle-social:dev Dec 17, 2024
2 checks passed
staab pushed a commit that referenced this pull request Dec 17, 2024
* local read receipts for notifications

* local read receipts for channels

* - fix read notification infinite loop
- move notifications.ts to /engine/

* clean notifications import

* - specific notifications prefix for channels
- removed unused notification's subscriptions

* path based seen check
staab pushed a commit that referenced this pull request Dec 30, 2024
* local read receipts for notifications

* local read receipts for channels

* - fix read notification infinite loop
- move notifications.ts to /engine/

* clean notifications import

* - specific notifications prefix for channels
- removed unused notification's subscriptions

* path based seen check
staab pushed a commit that referenced this pull request Jan 15, 2025
* local read receipts for notifications

* local read receipts for channels

* - fix read notification infinite loop
- move notifications.ts to /engine/

* clean notifications import

* - specific notifications prefix for channels
- removed unused notification's subscriptions

* path based seen check
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.

2 participants