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

Allow users to force notifications to be marked as read #2248

Merged
merged 14 commits into from
Jul 26, 2024

Conversation

Silver-IT
Copy link
Member

@Silver-IT Silver-IT requested a review from taoeffect July 23, 2024 07:48
@Silver-IT Silver-IT self-assigned this Jul 23, 2024
@Silver-IT Silver-IT linked an issue Jul 23, 2024 that may be closed by this pull request
Copy link

cypress bot commented Jul 23, 2024

Passing run #2819 ↗︎

0 112 10 0 Flakiness 0

Details:

Merge 09f3b3e into eea332d...
Project: group-income Commit: c894e4dd07 ℹ️
Status: Passed Duration: 10:37 💡
Started: Jul 26, 2024 7:51 PM Ended: Jul 26, 2024 8:01 PM

Review all test suite changes for PR #2248 ↗︎

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Question: I don't see how this PR will help sync the existing status of the notification back to the client. This seems to be modifying the action of marking all notifications as read, but where is the code for grabbing the latest value of a notification's read status? Is that what should be fixed?

@Silver-IT
Copy link
Member Author

Question: I don't see how this PR will help sync the existing status of the notification back to the client. This seems to be modifying the action of marking all notifications as read, but where is the code for grabbing the latest value of a notification's read status? Is that what should be fixed?

Actually, the syncing notifications status is already implemented. I guess the reason of the difference status between two devices is because that there could be a network issue in one device. So it could fail to listen the KV event and to update notification status on this device.
Actually, the syncing contracts could also be failed when there is a network issue. I also faced this kind of problem while I was testing on my side. Syncing an identity contract was failed, and can not display username (or displayname) only for one member. I investigated this issue and noticed that it was because that his identity contract was not fully synced.

So what I did in this PR is to allow users to force updating the notifications read status. When the user clicks Mark all as read, 'gi.actions/identity/kv/markNotificationStatusRead' function will be executed even though the values of KV store are already updated. Actually, this function call won't make any changes on KV store side, but an event will be emitted on backend side which will update the notification status of all the devices where the event is being listened.

Actually, there could be two choices.
One is to allow users to force updating notifications status and to get updated to the latest KV store values
And the other is to call 'gi.actions/identity/kv/loadNotificationStatus' function every time users open the notification card.

I thought the first one is better in terms of performance, so I worked on it.

@taoeffect, do you think there is a real bug in listening KV event? If not, which option do you prefer?

@taoeffect
Copy link
Member

taoeffect commented Jul 25, 2024

And the other is to call 'gi.actions/identity/kv/loadNotificationStatus' function every time users open the notification card.

I don't see how that would help, because this is already called on login by 'gi.actions/identity/kv/load', and yet the notification status isn't updated on page refresh. So can you investigate why that is?

@Silver-IT
Copy link
Member Author

I don't see how that would help, because this is already called on login by 'gi.actions/identity/kv/load', and yet the notification status isn't updated on page refresh.

That makes sense.

So can you investigate why that is?

As I have already said in here, I couldn't have any chance to encounter this issue on my side. I tried many times, but never encountered. So, it is difficult to investigate.

@taoeffect
Copy link
Member

As I have already said in #2235 (comment), I couldn't have any chance to encounter this issue on my side. I tried many times, but never encountered. So, it is difficult to investigate.

Here's something you can try:

  • use https://localhost.run/
  • device 1 (desktop) invites device 2 (phone) to group
  • add 3rd user and create proposal
  • device 1 has its internet connection turned off
  • device 2 marks notification as read
  • device 1 comes back online

Then do that again if the problem doesn't reproduce, but switch device 1 and device 2 (e.g. if device 1 was desktop, make it phone).

@Silver-IT
Copy link
Member Author

@taoeffect, with your recommended workflow, I can see the the second device doesn't get updated with the notifications status even though refresh the browser. After some investigation, I have noticed that we should call sbp('gi.actions/identity/kv/load') in other place in main.js. Please have a look at the updates.

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Great work @Silver-IT !!!

Minor request for error handling please:

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Actually, one more change request: we want to call sbp('gi.actions/identity/kv/load') when we come back online, so could you please do the following:

  1. Add an event to events.js called ONLINE
  2. emit this event in main.js in the online handler EDIT: and the 'reconnection-succeeded' handler too
  3. listen for this event in identity-kv.js and call sbp('gi.actions/identity/kv/load') in the event listener (please copy the same .catch handler, but modify the error message to make it clear that the error happened in the online handler, instead of during login)

@taoeffect
Copy link
Member

taoeffect commented Jul 26, 2024

When I run grunt test locally on this branch I get this heisenbug error as well: #2257

So this PR seems to result in two common heisenbugs:

….js + improvements

+ Reverted changes to group-chat.spec.js because they weren't fixing anything and the tests are passing locally on my machine
+ Updated group-proposals.spec.js to fix a weird possible Heisenbug by enabling a bypassUI (because that test was failing on my machine)
+ Updated main.js to emit ONLINE for online event handler as well + added related console.info logging
taoeffect

This comment was marked as outdated.

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Great work @Silver-IT ! (And @taoeffect). To deal with the heisenbug I've commented out the problematic line for now and updated issue #2256.

@taoeffect taoeffect merged commit 43612ed into master Jul 26, 2024
4 checks passed
@taoeffect taoeffect deleted the 2235-notifications-unread-status-not-being-sync branch July 26, 2024 20:15
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.

Notifications unread status not being sync
2 participants