Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Change ListNotificationState to store room ids #9518

Conversation

Arnei
Copy link
Contributor

@Arnei Arnei commented Oct 28, 2022

ListNotificationState stores a reference to a rooms array which is later used for comparing the stored array with new arrays. However, the comparison may fail since the stored array can be changed outside the class. This PR proposes to instead store only the room ids, which hopefully allows to avoid the issue by copying the room ids into a new array, while still being performant.

For example, the problem that prompted this PR is that when you leave a room with unread notifications the "rooms" list still shows the notification badge with the number of unread notifications, even though there are no more rooms with notifications.
Screenshot_from_2022-10-05_10-42-25
With this PR, the notification badge will be correctly displayed at the "archive" list.

Signed-off-by: Arne Wilken arnepokemon@yahoo.de

type: defect

Notes: Fix incorrect notification count after leaving a room with notifications
element-web notes: Fix incorrect notification count after leaving a room with notifications


Here's what your changelog entry will look like:

🐛 Bug Fixes

  • Fix incorrect notification count after leaving a room with notifications (#9518). Contributed by @Arnei.

ListNotificationState stores a reference to a rooms array which is later
used for comparing the stored array with new arrays. However, the
comparison may fail since the stored array can be changed outside the
class. This PR proposes to instead store only the room ids, which
hopefully allows to avoid the issue by copying the room ids into
a new array, while still being performant.

Signed-off-by: Arne Wilken arnepokemon@yahoo.de
@Arnei Arnei requested a review from a team as a code owner October 28, 2022 13:19
@github-actions github-actions bot added Z-Community-PR Issue is solved by a community member's PR T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems labels Oct 28, 2022
Instead of using room ids like in the previous commit,
shallow clone the rooms array instead.
…ng-after-deleting-room' into fix-unread-notifications-remaining-after-deleting-room
@richvdh richvdh changed the title Changed ListNotificationState to store room ids Change ListNotificationState to store room ids Nov 1, 2022
@robintown robintown enabled auto-merge (squash) November 1, 2022 20:39
@robintown
Copy link
Member

Thanks!

@robintown robintown merged commit 1e65dcd into matrix-org:develop Nov 1, 2022
su-ex added a commit to SchildiChat/element-desktop that referenced this pull request Nov 25, 2022
* Switch to notarytool ([\element-hq#440](element-hq#440)).
* Make clear notifications work with threads ([\#9575](matrix-org/matrix-react-sdk#9575)). Fixes element-hq/element-web#23751.
* Change "None" to "Off" in notification options ([\#9539](matrix-org/matrix-react-sdk#9539)). Contributed by @Arnei.
* Advanced audio processing settings ([\#8759](matrix-org/matrix-react-sdk#8759)). Fixes element-hq/element-web#6278. Contributed by @MrAnno.
* Add way to create a user notice via config.json ([\#9559](matrix-org/matrix-react-sdk#9559)).
* Improve design of the rich text editor ([\#9533](matrix-org/matrix-react-sdk#9533)).
* Enable user to zoom beyond image size ([\#5949](matrix-org/matrix-react-sdk#5949)). Contributed by @jaiwanth-v.
* Fix: Move "Leave Space" option to the bottom of space context menu ([\#9535](matrix-org/matrix-react-sdk#9535)). Contributed by @hanadi92.
* Fix encrypted message search indexing for non-default `--profile` instances. ([\element-hq#433](element-hq#433)).
* Make build scripts work on NixOS ([\#23740](element-hq/element-web#23740)).
* Fix integration manager `get_open_id_token` action and add E2E tests ([\#9520](matrix-org/matrix-react-sdk#9520)).
* Fix links being mangled by markdown processing ([\#9570](matrix-org/matrix-react-sdk#9570)). Fixes element-hq/element-web#23743.
* Fix: inline links selecting radio button ([\#9543](matrix-org/matrix-react-sdk#9543)). Contributed by @hanadi92.
* fix wrong error message in registration when phone number threepid is in use. ([\#9571](matrix-org/matrix-react-sdk#9571)). Contributed by @bagvand.
* Fix missing avatar for show current profiles ([\#9563](matrix-org/matrix-react-sdk#9563)). Fixes element-hq/element-web#23733.
* fix read receipts trickling down correctly ([\#9567](matrix-org/matrix-react-sdk#9567)). Fixes element-hq/element-web#23746.
* Resilience fix for homeserver without thread notification support ([\#9565](matrix-org/matrix-react-sdk#9565)).
* Don't switch to the home page needlessly after leaving a room ([\#9477](matrix-org/matrix-react-sdk#9477)).
* Differentiate download and decryption errors when showing images ([\#9562](matrix-org/matrix-react-sdk#9562)). Fixes element-hq/element-web#3892.
* Close context menu when a modal is opened to prevent user getting stuck ([\#9560](matrix-org/matrix-react-sdk#9560)). Fixes element-hq/element-web#15610 and element-hq/element-web#10781.
* Fix TimelineReset handling when no room associated ([\#9553](matrix-org/matrix-react-sdk#9553)).
* Always use current profile on thread events ([\#9524](matrix-org/matrix-react-sdk#9524)). Fixes element-hq/element-web#23648.
* Fix `ThreadView` tests not using thread flag ([\#9547](matrix-org/matrix-react-sdk#9547)).
* Fix regressions around media uploads failing and causing soft crashes ([\#9549](matrix-org/matrix-react-sdk#9549)). Fixes matrix-org/element-web-rageshakes#16831, matrix-org/element-web-rageshakes#16824 matrix-org/element-web-rageshakes#16810 and element-hq/element-web#23641.
* Handle deletion of `m.call` events ([\#9540](matrix-org/matrix-react-sdk#9540)). Fixes element-hq/element-web#23663.
* Fix /myroomavatar slash command ([\#9536](matrix-org/matrix-react-sdk#9536)). Fixes matrix-org/synapse#14321.
* Fix incorrect notification count after leaving a room with notifications ([\#9518](matrix-org/matrix-react-sdk#9518)). Contributed by @Arnei.
su-ex added a commit to SchildiChat/element-web that referenced this pull request Nov 25, 2022
* Make clear notifications work with threads ([\element-hq#9575](matrix-org/matrix-react-sdk#9575)). Fixes element-hq#23751.
* Change "None" to "Off" in notification options ([\element-hq#9539](matrix-org/matrix-react-sdk#9539)). Contributed by @Arnei.
* Advanced audio processing settings ([\element-hq#8759](matrix-org/matrix-react-sdk#8759)). Fixes element-hq#6278. Contributed by @MrAnno.
* Add way to create a user notice via config.json ([\element-hq#9559](matrix-org/matrix-react-sdk#9559)).
* Improve design of the rich text editor ([\element-hq#9533](matrix-org/matrix-react-sdk#9533)). Contributed by @florianduros.
* Enable user to zoom beyond image size ([\element-hq#5949](matrix-org/matrix-react-sdk#5949)). Contributed by @jaiwanth-v.
* Fix: Move "Leave Space" option to the bottom of space context menu ([\element-hq#9535](matrix-org/matrix-react-sdk#9535)). Contributed by @hanadi92.
* Make build scripts work on NixOS ([\element-hq#23740](element-hq#23740)).
* Fix integration manager `get_open_id_token` action and add E2E tests ([\element-hq#9520](matrix-org/matrix-react-sdk#9520)).
* Fix links being mangled by markdown processing ([\element-hq#9570](matrix-org/matrix-react-sdk#9570)). Fixes element-hq#23743.
* Fix: inline links selecting radio button ([\element-hq#9543](matrix-org/matrix-react-sdk#9543)). Contributed by @hanadi92.
* Fix wrong error message in registration when phone number threepid is in use. ([\element-hq#9571](matrix-org/matrix-react-sdk#9571)). Contributed by @bagvand.
* Fix missing avatar for show current profiles ([\element-hq#9563](matrix-org/matrix-react-sdk#9563)). Fixes element-hq#23733.
* Fix read receipts trickling down correctly ([\element-hq#9567](matrix-org/matrix-react-sdk#9567)). Fixes element-hq#23746.
* Resilience fix for homeserver without thread notification support ([\element-hq#9565](matrix-org/matrix-react-sdk#9565)).
* Don't switch to the home page needlessly after leaving a room ([\element-hq#9477](matrix-org/matrix-react-sdk#9477)).
* Differentiate download and decryption errors when showing images ([\element-hq#9562](matrix-org/matrix-react-sdk#9562)). Fixes element-hq#3892.
* Close context menu when a modal is opened to prevent user getting stuck ([\element-hq#9560](matrix-org/matrix-react-sdk#9560)). Fixes element-hq#15610 and element-hq#10781.
* Fix TimelineReset handling when no room associated ([\element-hq#9553](matrix-org/matrix-react-sdk#9553)).
* Always use current profile on thread events ([\#9524](matrix-org/matrix-react-sdk#9524)). Fixes element-hq#23648.
* Fix `ThreadView` tests not using thread flag ([\element-hq#9547](matrix-org/matrix-react-sdk#9547)). Contributed by @MadLittleMods.
* Handle deletion of `m.call` events ([\element-hq#9540](matrix-org/matrix-react-sdk#9540)). Fixes element-hq#23663.
* Fix incorrect notification count after leaving a room with notifications ([\element-hq#9518](matrix-org/matrix-react-sdk#9518)). Contributed by @Arnei.
su-ex added a commit to SchildiChat/matrix-react-sdk that referenced this pull request Nov 25, 2022
* Make clear notifications work with threads ([\matrix-org#9575](matrix-org#9575)). Fixes element-hq/element-web#23751.
* Change "None" to "Off" in notification options ([\matrix-org#9539](matrix-org#9539)). Contributed by @Arnei.
* Advanced audio processing settings ([\matrix-org#8759](matrix-org#8759)). Fixes element-hq/element-web#6278. Contributed by @MrAnno.
* Add way to create a user notice via config.json ([\matrix-org#9559](matrix-org#9559)).
* Improve design of the rich text editor ([\matrix-org#9533](matrix-org#9533)). Contributed by @florianduros.
* Enable user to zoom beyond image size ([\matrix-org#5949](matrix-org#5949)). Contributed by @jaiwanth-v.
* Fix: Move "Leave Space" option to the bottom of space context menu ([\matrix-org#9535](matrix-org#9535)). Contributed by @hanadi92.
* Fix integration manager `get_open_id_token` action and add E2E tests ([\matrix-org#9520](matrix-org#9520)).
* Fix links being mangled by markdown processing ([\matrix-org#9570](matrix-org#9570)). Fixes element-hq/element-web#23743.
* Fix: inline links selecting radio button ([\matrix-org#9543](matrix-org#9543)). Contributed by @hanadi92.
* fix wrong error message in registration when phone number threepid is in use. ([\matrix-org#9571](matrix-org#9571)). Contributed by @bagvand.
* Fix missing avatar for show current profiles ([\matrix-org#9563](matrix-org#9563)). Fixes element-hq/element-web#23733.
* fix read receipts trickling down correctly ([\matrix-org#9567](matrix-org#9567)). Fixes element-hq/element-web#23746.
* Resilience fix for homeserver without thread notification support ([\matrix-org#9565](matrix-org#9565)).
* Don't switch to the home page needlessly after leaving a room ([\matrix-org#9477](matrix-org#9477)).
* Differentiate download and decryption errors when showing images ([\matrix-org#9562](matrix-org#9562)). Fixes element-hq/element-web#3892.
* Close context menu when a modal is opened to prevent user getting stuck ([\matrix-org#9560](matrix-org#9560)). Fixes element-hq/element-web#15610 and element-hq/element-web#10781.
* Fix TimelineReset handling when no room associated ([\matrix-org#9553](matrix-org#9553)).
* Always use current profile on thread events ([\matrix-org#9524](matrix-org#9524)). Fixes element-hq/element-web#23648.
* Fix `ThreadView` tests not using thread flag ([\matrix-org#9547](matrix-org#9547)). Contributed by @MadLittleMods.
* Handle deletion of `m.call` events ([\matrix-org#9540](matrix-org#9540)). Fixes element-hq/element-web#23663.
* Fix incorrect notification count after leaving a room with notifications ([\matrix-org#9518](matrix-org#9518)). Contributed by @Arnei.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Dec 10, 2022
# Changes in [1.11.16](https://github.com/vector-im/element-web/releases/tag/v1.11.16) (2022-12-06)

## ✨ Features

-   Further improve replies ([\#6396](matrix-org/matrix-react-sdk#6396)). Fixes #19074, #18194 #18027 and #19179.
-   Enable users to join group calls from multiple devices ([\#9625](matrix-org/matrix-react-sdk#9625)).
-   fix(visual): make cursor a pointer for summaries ([\#9419](matrix-org/matrix-react-sdk#9419)). Contributed by @r00ster91.
-   Add placeholder for rich text editor ([\#9613](matrix-org/matrix-react-sdk#9613)).
-   Consolidate public room search experience ([\#9605](matrix-org/matrix-react-sdk#9605)). Fixes #22846.
-   New password reset flow ([\#9581](matrix-org/matrix-react-sdk#9581)). Fixes #23131.
-   Device manager - add tooltip to device details toggle ([\#9594](matrix-org/matrix-react-sdk#9594)).
-   sliding sync: add lazy-loading member support ([\#9530](matrix-org/matrix-react-sdk#9530)).
-   Limit formatting bar offset to top of composer ([\#9365](matrix-org/matrix-react-sdk#9365)). Fixes #12359. Contributed by @owi92.

## 🐛 Bug Fixes

-   Fix issues around up arrow event edit shortcut ([\#9645](matrix-org/matrix-react-sdk#9645)). Fixes #18497 and #18964.
-   Fix search not being cleared when clicking on a result ([\#9635](matrix-org/matrix-react-sdk#9635)). Fixes #23845.
-   Fix screensharing in 1:1 calls ([\#9612](matrix-org/matrix-react-sdk#9612)). Fixes #23808.
-   Fix the background color flashing when joining a call ([\#9640](matrix-org/matrix-react-sdk#9640)).
-   Fix the size of the 'Private space' icon ([\#9638](matrix-org/matrix-react-sdk#9638)).
-   Fix reply editing in rich text editor (https ([\#9615](matrix-org/matrix-react-sdk#9615)).
-   Fix thread list jumping back down while scrolling ([\#9606](matrix-org/matrix-react-sdk#9606)). Fixes #23727.
-   Fix regression with TimelinePanel props updates not taking effect ([\#9608](matrix-org/matrix-react-sdk#9608)). Fixes #23794.
-   Fix form tooltip positioning ([\#9598](matrix-org/matrix-react-sdk#9598)). Fixes #22861.
-   Extract Search handling from RoomView into its own Component ([\#9574](matrix-org/matrix-react-sdk#9574)). Fixes #498.
-   Fix call splitbrains when switching between rooms ([\#9692](matrix-org/matrix-react-sdk#9692)).
-   [Backport staging] Fix replies to emotes not showing as inline ([\#9708](matrix-org/matrix-react-sdk#9708)).

# Changes in [1.11.15](https://github.com/vector-im/element-web/releases/tag/v1.11.15) (2022-11-22)

## ✨ Features

-   Make clear notifications work with threads ([\#9575](matrix-org/matrix-react-sdk#9575)). Fixes #23751.
-   Change "None" to "Off" in notification options ([\#9539](matrix-org/matrix-react-sdk#9539)). Contributed by @Arnei.
-   Advanced audio processing settings ([\#8759](matrix-org/matrix-react-sdk#8759)). Fixes #6278. Contributed by @MrAnno.
-   Add way to create a user notice via config.json ([\#9559](matrix-org/matrix-react-sdk#9559)).
-   Improve design of the rich text editor ([\#9533](matrix-org/matrix-react-sdk#9533)). Contributed by @florianduros.
-   Enable user to zoom beyond image size ([\#5949](matrix-org/matrix-react-sdk#5949)). Contributed by @jaiwanth-v.
-   Fix: Move "Leave Space" option to the bottom of space context menu ([\#9535](matrix-org/matrix-react-sdk#9535)). Contributed by @hanadi92.

## 🐛 Bug Fixes

-   Make build scripts work on NixOS ([\#23740](element-hq/element-web#23740)).
-   Fix integration manager `get_open_id_token` action and add E2E tests ([\#9520](matrix-org/matrix-react-sdk#9520)).
-   Fix links being mangled by markdown processing ([\#9570](matrix-org/matrix-react-sdk#9570)). Fixes #23743.
-   Fix: inline links selecting radio button ([\#9543](matrix-org/matrix-react-sdk#9543)). Contributed by @hanadi92.
-   Fix wrong error message in registration when phone number threepid is in use. ([\#9571](matrix-org/matrix-react-sdk#9571)). Contributed by @bagvand.
-   Fix missing avatar for show current profiles ([\#9563](matrix-org/matrix-react-sdk#9563)). Fixes #23733.
-   Fix read receipts trickling down correctly ([\#9567](matrix-org/matrix-react-sdk#9567)). Fixes #23746.
-   Resilience fix for homeserver without thread notification support ([\#9565](matrix-org/matrix-react-sdk#9565)).
-   Don't switch to the home page needlessly after leaving a room ([\#9477](matrix-org/matrix-react-sdk#9477)).
-   Differentiate download and decryption errors when showing images ([\#9562](matrix-org/matrix-react-sdk#9562)). Fixes #3892.
-   Close context menu when a modal is opened to prevent user getting stuck ([\#9560](matrix-org/matrix-react-sdk#9560)). Fixes #15610 and #10781.
-   Fix TimelineReset handling when no room associated ([\#9553](matrix-org/matrix-react-sdk#9553)).
-   Always use current profile on thread events ([\#9524](matrix-org/matrix-react-sdk#9524)). Fixes #23648.
-   Fix `ThreadView` tests not using thread flag ([\#9547](matrix-org/matrix-react-sdk#9547)). Contributed by @MadLittleMods.
-   Handle deletion of `m.call` events ([\#9540](matrix-org/matrix-react-sdk#9540)). Fixes #23663.
-   Fix incorrect notification count after leaving a room with notifications ([\#9518](matrix-org/matrix-react-sdk#9518)). Contributed by @Arnei.

# Changes in [1.11.14](https://github.com/vector-im/element-web/releases/tag/v1.11.14) (2022-11-08)

## ✨ Features

-   Loading threads with server-side assistance ([\#9356](matrix-org/matrix-react-sdk#9356)). Fixes #21807, #21799, #21911, #22141, #22157, #22641, #22501 #22438 and #21678. Contributed by @justjanne.
-   Make thread replies trigger a room list re-ordering ([\#9510](matrix-org/matrix-react-sdk#9510)). Fixes #21700.
-   Device manager - add extra details to device security and renaming ([\#9501](matrix-org/matrix-react-sdk#9501)). Contributed by @kerryarchibald.
-   Add plain text mode to the wysiwyg composer ([\#9503](matrix-org/matrix-react-sdk#9503)). Contributed by @florianduros.
-   Sliding Sync: improve sort order, show subspace rooms, better tombstoned room handling ([\#9484](matrix-org/matrix-react-sdk#9484)).
-   Device manager - add learn more popups to filtered sessions section ([\#9497](matrix-org/matrix-react-sdk#9497)). Contributed by @kerryarchibald.
-   Show thread notification if thread timeline is closed ([\#9495](matrix-org/matrix-react-sdk#9495)). Fixes #23589.
-   Add message editing to wysiwyg composer ([\#9488](matrix-org/matrix-react-sdk#9488)). Contributed by @florianduros.
-   Device manager - confirm sign out of other sessions ([\#9487](matrix-org/matrix-react-sdk#9487)). Contributed by @kerryarchibald.
-   Automatically request logs from other users in a call when submitting logs ([\#9492](matrix-org/matrix-react-sdk#9492)).
-   Add thread notification with server assistance (MSC3773) ([\#9400](matrix-org/matrix-react-sdk#9400)). Fixes #21114, #21413, #21416, #21433, #21481, #21798, #21823 #23192 and #21765.
-   Support for login + E2EE set up with QR ([\#9403](matrix-org/matrix-react-sdk#9403)). Contributed by @hughns.
-   Allow pressing Enter to send messages in new composer ([\#9451](matrix-org/matrix-react-sdk#9451)). Contributed by @andybalaam.

## 🐛 Bug Fixes

-   Fix regressions around media uploads failing and causing soft crashes ([\#9549](matrix-org/matrix-react-sdk#9549)). Fixes matrix-org/element-web-rageshakes#16831, matrix-org/element-web-rageshakes#16824 matrix-org/element-web-rageshakes#16810 and element-hq/element-web#23641.
-   Fix /myroomavatar slash command ([\#9536](matrix-org/matrix-react-sdk#9536)). Fixes matrix-org/synapse#14321.
-   Fix config.json failing to load for Jitsi wrapper in non-root deployment ([\#23577](element-hq/element-web#23577)).
-   Fix NotificationBadge unsent color ([\#9522](matrix-org/matrix-react-sdk#9522)). Fixes #23646.
-   Fix room list sorted by recent on app startup ([\#9515](matrix-org/matrix-react-sdk#9515)). Fixes #23635.
-   Reset custom power selector when blurred on empty ([\#9508](matrix-org/matrix-react-sdk#9508)). Fixes #23481.
-   Reinstate timeline/redaction callbacks when updating notification state ([\#9494](matrix-org/matrix-react-sdk#9494)). Fixes #23554.
-   Only render NotificationBadge when needed ([\#9493](matrix-org/matrix-react-sdk#9493)). Fixes #23584.
-   Fix embedded Element Call screen sharing ([\#9485](matrix-org/matrix-react-sdk#9485)). Fixes #23571.
-   Send Content-Type: application/json header for integration manager /register API ([\#9490](matrix-org/matrix-react-sdk#9490)). Fixes #23580.
-   Fix joining calls without audio or video inputs ([\#9486](matrix-org/matrix-react-sdk#9486)). Fixes #23511.
-   Ensure spaces in the spotlight dialog have rounded square avatars ([\#9480](matrix-org/matrix-react-sdk#9480)). Fixes #23515.
-   Only show mini avatar uploader in room intro when no avatar yet exists ([\#9479](matrix-org/matrix-react-sdk#9479)). Fixes #23552.
-   Fix threads fallback incorrectly targets root event ([\#9229](matrix-org/matrix-react-sdk#9229)). Fixes #23147.
-   Align video call icon with banner text ([\#9460](matrix-org/matrix-react-sdk#9460)).
-   Set relations helper when creating event tile context menu ([\#9253](matrix-org/matrix-react-sdk#9253)). Fixes #22018.
-   Device manager - put client/browser device metadata in correct section ([\#9447](matrix-org/matrix-react-sdk#9447)). Contributed by @kerryarchibald.
-   Update the room unread notification counter when the server changes the value without any related read receipt ([\#9438](matrix-org/matrix-react-sdk#9438)).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants