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

Notifications not sent on edge case #1892

Open
TrojanerHD opened this issue Aug 13, 2024 · 0 comments
Open

Notifications not sent on edge case #1892

TrojanerHD opened this issue Aug 13, 2024 · 0 comments

Comments

@TrojanerHD
Copy link

Describe the bug

Upon someone sending a message and you opening the room, then unfocusing / changing the room again and someone sending a message with the same amount of highlights in the same room directly afterward, no notification about the message is shown

Reproduction

You need two accounts (A1, A2)

  1. Open Cinny with A1 while not in the test room
  2. Send a message with A2 into the test room (you should get a notification in Cinny)
  3. Open the room with A1
  4. Close the room again (e.g. click on Home)
  5. Send another message with A2 into the test room
  6. A1 gets no notification in Cinny

Expected behavior

A1 should get a notification

Platform and versions

1. OS: Arch Linux
2. Browser: LibreWolf
3. Cinny version: https://github.com/cinnyapp/cinny/commit/5058136737e177a5cabecc8b53b489eaabc23429 (dev branch at time of writing)
4. Matrix homeserver: A1: matrix.org, A2: trojaner.dev

Additional context

A friend noticed he didn't get notifications consistently so I dug into the code and found a problem in this snippet:

const unreadInfo = getUnreadInfo(room);
const cachedUnreadInfo = unreadCacheRef.current.get(room.roomId);
unreadCacheRef.current.set(room.roomId, unreadInfo);
if (unreadInfo.total === 0) return;
if (
cachedUnreadInfo &&
unreadEqual(unreadInfoToUnread(cachedUnreadInfo), unreadInfoToUnread(unreadInfo))
) {
return;
}

Assume, you get a notification with unreadInfo = { total: 1, room_id: <test room id>, highlight: 0 }. unreadCacheRef is set to that info directly afterward. So far, so good.

You then read the message and another message is sent into the room. Now, an unreadInfo with the same parameters is retrieved, thus the check below is true (as now the cachedUnreadInfo is set to unreadCacheRef, i.e., the previous unreadInfo). So the function returns instead of sending a notification. I could reproduce this exact problem by building from source and setting a debugger in LibreWolf which would, in fact, exit this function exactly there.

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

No branches or pull requests

1 participant