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

Display rooms & threads as unread (bold) if threads have unread messages. #9763

Merged
merged 14 commits into from
Jan 11, 2023

Conversation

clokep
Copy link
Member

@clokep clokep commented Dec 14, 2022

Re-apply the changes from 9de5654 (#9723) which were reverted in 9668a24 (#9745); also incorporates #9738 and #9739.

This fixes 3 related bits of notifications due to room activity:

  • The room (in the room list) should appear as bold on new events in any thread in the room.
  • The thread (in the threads list) should appear bold on new activity in that thread.
  • The thread icon should get a badge if any threads have new activity.

The logic for all of these is essentially separate (instead of bubbling up from threads -> thread list -> room or something like that), so there are 3 separate changes made.

Fixes element-hq/element-web#23907

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Here's what your changelog entry will look like:

🐛 Bug Fixes

test/test-utils/threads.ts Outdated Show resolved Hide resolved
@clokep clokep added the T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems label Dec 14, 2022
src/Unread.ts Outdated
return false;
}

export function doesRoomOrThreadHaveUnreadMessages(room: Room | Thread): boolean {
Copy link
Member Author

Choose a reason for hiding this comment

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

(Mostly choosing a random place to start a thread.)

We need to figure out how to handle threads that exist before this change or users will see many rooms marked as unread as threads that exited before MSC3771 will likely not have a read receipt and will appear as unread.

Copy link
Member Author

Choose a reason for hiding this comment

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

@gsouquet I think you were going to write a bit about our options here? From what I remember of our conversation we want to mark any "existing" threads as read up to their current point when this rolls out (so we don't mark all "old" threads as unread). Potential options:

  1. Send a read receipt in each thread to the server and receive them down sync. (This likely wouldn't work since we would essentially DoS the server & we don't load all threads on load anyway.)
  2. Mark any threads before a certain time as read. This isn't desirable since different people will start using the new code at different times.

I'm not sure we came up with others (besides something about changing the entire storage of events to be closer to what mobile does).

Copy link
Contributor

Choose a reason for hiding this comment

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

We have discussed this during a web meeting last week.
One alternative approach that has not been listed above is to figure out for each room when the first threaded read receipt has been sent and to discard all the threads that haven't received an update since that point in time from the computation made in this pull request

Sounds like the most sensible thing to do, we might need to force an initial sync, to make sure we have access to that data

Copy link
Member Author

Choose a reason for hiding this comment

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

when the first threaded read receipt has been sent and to discard all the threads that haven't received an update since that point in time from the computation made in this pull request

How do we compare "when" this way? Using the ts of the receipt and the origin_server_ts of the events?

Copy link
Member Author

@clokep clokep Jan 5, 2023

Choose a reason for hiding this comment

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

This work is now essentially in matrix-org/matrix-js-sdk#3020 matrix-org/matrix-js-sdk#3031, although we might need more tweaks here.

Comment on lines +159 to +169
// Notification badge may change if the notification counts from the
// server change, if a new thread is created or updated, or if a
// receipt is sent in the thread.
this.props.room?.on(RoomEvent.UnreadNotifications, this.onNotificationUpdate);
this.props.room?.on(RoomEvent.Receipt, this.onNotificationUpdate);
this.props.room?.on(RoomEvent.Timeline, this.onNotificationUpdate);
this.props.room?.on(RoomEvent.Redaction, this.onNotificationUpdate);
this.props.room?.on(RoomEvent.LocalEchoUpdated, this.onNotificationUpdate);
this.props.room?.on(RoomEvent.MyMembership, this.onNotificationUpdate);
this.props.room?.on(ThreadEvent.New, this.onNotificationUpdate);
this.props.room?.on(ThreadEvent.Update, this.onNotificationUpdate);
Copy link
Member Author

Choose a reason for hiding this comment

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

These are mostly copied from useUnreadNotifications:

useEventEmitter(
room,
RoomEvent.UnreadNotifications,
(unreadNotifications: NotificationCount, evtThreadId?: string) => {
// Discarding all events not related to the thread if one has been setup
if (threadId && threadId !== evtThreadId) return;
updateNotificationState();
},
);
useEventEmitter(room, RoomEvent.Receipt, () => updateNotificationState());
useEventEmitter(room, RoomEvent.Timeline, () => updateNotificationState());
useEventEmitter(room, RoomEvent.Redaction, () => updateNotificationState());
useEventEmitter(room, RoomEvent.LocalEchoUpdated, () => updateNotificationState());
useEventEmitter(room, RoomEvent.MyMembership, () => updateNotificationState());

Copy link
Contributor

@germain-gg germain-gg left a comment

Choose a reason for hiding this comment

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

Code looks good to me!
There's some type error where you're using React.ReactElement but React testing library yields HTMLElement rather than a React Element.

It also seem that some recent changes have made some tests regress.

src/Unread.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@germain-gg germain-gg left a comment

Choose a reason for hiding this comment

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

And that now looks good to me 👍

We should re-run the CI once matrix-org/matrix-js-sdk#3031 has landed, and we'll be ready to merge it.

@t3chguy t3chguy added the X-Release-Blocker This affects the current release cycle and must be solved for a release to happen label Jan 11, 2023
@germain-gg germain-gg merged commit da2640b into matrix-org:develop Jan 11, 2023
@clokep clokep deleted the unread-threads branch January 11, 2023 11:50
andybalaam pushed a commit to andybalaam/matrix-react-sdk that referenced this pull request Jan 12, 2023
…ges. (matrix-org#9763)

Co-authored-by: Germain <germain@souquet.com>
Co-authored-by: Germain <germains@element.io>
Fixes element-hq/element-web#23907
su-ex added a commit to SchildiChat/element-desktop that referenced this pull request Jan 19, 2023
* Switch threads on for everyone ([\#9879](matrix-org/matrix-react-sdk#9879)).
* Make threads use new Unable to Decrypt UI ([\#9876](matrix-org/matrix-react-sdk#9876)). Fixes element-hq/element-web#24060.
* Add edit and remove actions to link in RTE ([\#9864](matrix-org/matrix-react-sdk#9864)).
* Remove extensible events v1 experimental rendering ([\#9881](matrix-org/matrix-react-sdk#9881)).
* Make create poll dialog scale better (PSG-929) ([\#9873](matrix-org/matrix-react-sdk#9873)). Fixes element-hq/element-web#21855.
* Change RTE mode icons ([\#9861](matrix-org/matrix-react-sdk#9861)).
* Device manager - prune client information events after remote sign out ([\#9874](matrix-org/matrix-react-sdk#9874)).
* Check connection before starting broadcast ([\#9857](matrix-org/matrix-react-sdk#9857)).
* Enable sent receipt for poll start events (PSG-962) ([\#9870](matrix-org/matrix-react-sdk#9870)).
* Change clear notifications to have more readable copy ([\#9867](matrix-org/matrix-react-sdk#9867)).
* Combine search results when the query is present in multiple successive messages ([\#9855](matrix-org/matrix-react-sdk#9855)). Fixes element-hq/element-web#3977. Contributed by @grimhilt.
* Disable bubbles for broadcasts ([\#9860](matrix-org/matrix-react-sdk#9860)). Fixes element-hq/element-web#24140.
* Enable reactions and replies for broadcasts ([\#9856](matrix-org/matrix-react-sdk#9856)). Fixes element-hq/element-web#24042.
* Improve switching between rich and plain editing modes ([\#9776](matrix-org/matrix-react-sdk#9776)).
* Redesign the picture-in-picture window ([\#9800](matrix-org/matrix-react-sdk#9800)). Fixes element-hq/element-web#23980.
* User on-boarding tasks now appear in a static order. ([\#9799](matrix-org/matrix-react-sdk#9799)). Contributed by @GoodGuyMarco.
* Device manager - contextual menus ([\#9832](matrix-org/matrix-react-sdk#9832)).
* If listening a non-live broadcast and changing the room, the broadcast will be paused ([\#9825](matrix-org/matrix-react-sdk#9825)). Fixes element-hq/element-web#24078.
* Consider own broadcasts from other device as a playback ([\#9821](matrix-org/matrix-react-sdk#9821)). Fixes element-hq/element-web#24068.
* Add link creation to rich text editor ([\#9775](matrix-org/matrix-react-sdk#9775)).
* Add mark as read option in room setting ([\#9798](matrix-org/matrix-react-sdk#9798)). Fixes element-hq/element-web#24053.
* Device manager - current device design and copy tweaks ([\#9801](matrix-org/matrix-react-sdk#9801)).
* Unify notifications panel event design ([\#9754](matrix-org/matrix-react-sdk#9754)).
* Add actions for integration manager to send and read certain events ([\#9740](matrix-org/matrix-react-sdk#9740)).
* Device manager - design tweaks ([\#9768](matrix-org/matrix-react-sdk#9768)).
* Change room list sorting to activity and unread first by default ([\#9773](matrix-org/matrix-react-sdk#9773)). Fixes element-hq/element-web#24014.
* Add a config flag to enable the rust crypto-sdk ([\#9759](matrix-org/matrix-react-sdk#9759)).
* Improve decryption error UI by consolidating error messages and providing instructions when possible ([\#9544](matrix-org/matrix-react-sdk#9544)). Contributed by @duxovni.
* Honor font settings in Element Call ([\#9751](matrix-org/matrix-react-sdk#9751)). Fixes element-hq/element-web#23661.
* Device manager - use deleteAccountData to prune device manager client information events ([\#9734](matrix-org/matrix-react-sdk#9734)).
* Display rooms & threads as unread (bold) if threads have unread messages. ([\#9763](matrix-org/matrix-react-sdk#9763)). Fixes element-hq/element-web#23907.
* Don't prefer STIXGeneral over the default font ([\#9711](matrix-org/matrix-react-sdk#9711)). Fixes element-hq/element-web#23899.
* Use the same avatar colour when creating 1:1 DM rooms ([\#9850](matrix-org/matrix-react-sdk#9850)). Fixes element-hq/element-web#23476.
* Fix space lock icon size ([\#9854](matrix-org/matrix-react-sdk#9854)). Fixes element-hq/element-web#24128.
* Make calls automatically disconnect if the widget disappears ([\#9862](matrix-org/matrix-react-sdk#9862)). Fixes element-hq/element-web#23664.
* Fix emoji in RTE editing ([\#9827](matrix-org/matrix-react-sdk#9827)).
* Fix export with attachments on formats txt and json ([\#9851](matrix-org/matrix-react-sdk#9851)). Fixes element-hq/element-web#24130. Contributed by @grimhilt.
* Fixed empty `Content-Type` for encrypted uploads ([\#9848](matrix-org/matrix-react-sdk#9848)). Contributed by @K3das.
* Fix sign-in instead link on password reset page ([\#9820](matrix-org/matrix-react-sdk#9820)). Fixes element-hq/element-web#24087.
* The seekbar now initially shows the current position ([\#9796](matrix-org/matrix-react-sdk#9796)). Fixes element-hq/element-web#24051.
* Fix: Editing a poll will silently change it to a closed poll ([\#9809](matrix-org/matrix-react-sdk#9809)). Fixes element-hq/element-web#23176.
* Make call tiles look less broken in the right panel ([\#9808](matrix-org/matrix-react-sdk#9808)). Fixes element-hq/element-web#23716.
* Prevent unnecessary m.direct updates ([\#9805](matrix-org/matrix-react-sdk#9805)). Fixes element-hq/element-web#24059.
* Fix checkForPreJoinUISI for thread roots ([\#9803](matrix-org/matrix-react-sdk#9803)). Fixes element-hq/element-web#24054.
* Snap in PiP widget when content changed ([\#9797](matrix-org/matrix-react-sdk#9797)). Fixes element-hq/element-web#24050.
* Load RTE components only when RTE labs is enabled ([\#9804](matrix-org/matrix-react-sdk#9804)).
* Ensure that events are correctly updated when they are edited. ([\#9789](matrix-org/matrix-react-sdk#9789)).
* When stopping a broadcast also stop the playback ([\#9795](matrix-org/matrix-react-sdk#9795)). Fixes element-hq/element-web#24052.
* Prevent to start two broadcasts at the same time ([\#9744](matrix-org/matrix-react-sdk#9744)). Fixes element-hq/element-web#23973.
* Correctly handle limited sync responses by resetting the thread timeline ([\#3056](matrix-org/matrix-js-sdk#3056)). Fixes element-hq/element-web#23952.
* Fix failure to start in firefox private browser ([\#3058](matrix-org/matrix-js-sdk#3058)). Fixes element-hq/element-web#24216.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 29, 2023
Changes in [1.11.20](https://github.com/vector-im/element-web/releases/tag/v1.11.20) (2023-01-20)
=================================================================================================

## 🐛 Bug Fixes
 * (Part 2) of prevent crash on older browsers (replace .at() with array.length-1)

Changes in [1.11.19](https://github.com/vector-im/element-web/releases/tag/v1.11.19) (2023-01-18)
=================================================================================================

## 🐛 Bug Fixes
 * fix crash on browsers that don't support `Array.at` ([\#9935](matrix-org/matrix-react-sdk#9935)). Contributed by @andybalaam.

Changes in [1.11.18](https://github.com/vector-im/element-web/releases/tag/v1.11.18) (2023-01-18)
=================================================================================================

## ✨ Features
 * Switch threads on for everyone ([\#9879](matrix-org/matrix-react-sdk#9879)).
 * Make threads use new Unable to Decrypt UI ([\#9876](matrix-org/matrix-react-sdk#9876)). Fixes #24060.
 * Add edit and remove actions to link in RTE [Labs] ([\#9864](matrix-org/matrix-react-sdk#9864)).
 * Remove extensible events v1 experimental rendering ([\#9881](matrix-org/matrix-react-sdk#9881)).
 * Make create poll dialog scale better (PSG-929) ([\#9873](matrix-org/matrix-react-sdk#9873)). Fixes #21855.
 * Change RTE mode icons ([\#9861](matrix-org/matrix-react-sdk#9861)).
 * Device manager - prune client information events after remote sign out ([\#9874](matrix-org/matrix-react-sdk#9874)).
 * Check connection before starting broadcast ([\#9857](matrix-org/matrix-react-sdk#9857)).
 * Enable sent receipt for poll start events (PSG-962) ([\#9870](matrix-org/matrix-react-sdk#9870)).
 * Change clear notifications to have more readable copy ([\#9867](matrix-org/matrix-react-sdk#9867)).
 * combine search results when the query is present in multiple successive messages ([\#9855](matrix-org/matrix-react-sdk#9855)). Fixes #3977. Contributed by @grimhilt.
 * Disable bubbles for broadcasts ([\#9860](matrix-org/matrix-react-sdk#9860)). Fixes #24140.
 * Enable reactions and replies for broadcasts ([\#9856](matrix-org/matrix-react-sdk#9856)). Fixes #24042.
 * Improve switching between rich and plain editing modes ([\#9776](matrix-org/matrix-react-sdk#9776)).
 * Redesign the picture-in-picture window ([\#9800](matrix-org/matrix-react-sdk#9800)). Fixes #23980.
 * User on-boarding tasks now appear in a static order. ([\#9799](matrix-org/matrix-react-sdk#9799)). Contributed by @GoodGuyMarco.
 * Device manager - contextual menus ([\#9832](matrix-org/matrix-react-sdk#9832)).
 * If listening a non-live broadcast and changing the room, the broadcast will be paused ([\#9825](matrix-org/matrix-react-sdk#9825)). Fixes #24078.
 * Consider own broadcasts from other device as a playback ([\#9821](matrix-org/matrix-react-sdk#9821)). Fixes #24068.
 * Add link creation to rich text editor ([\#9775](matrix-org/matrix-react-sdk#9775)).
 * Add mark as read option in room setting ([\#9798](matrix-org/matrix-react-sdk#9798)). Fixes #24053.
 * Device manager - current device design and copy tweaks ([\#9801](matrix-org/matrix-react-sdk#9801)).
 * Unify notifications panel event design ([\#9754](matrix-org/matrix-react-sdk#9754)).
 * Add actions for integration manager to send and read certain events ([\#9740](matrix-org/matrix-react-sdk#9740)).
 * Device manager - design tweaks ([\#9768](matrix-org/matrix-react-sdk#9768)).
 * Change room list sorting to activity and unread first by default ([\#9773](matrix-org/matrix-react-sdk#9773)). Fixes #24014.
 * Add a config flag to enable the rust crypto-sdk ([\#9759](matrix-org/matrix-react-sdk#9759)).
 * Improve decryption error UI by consolidating error messages and providing instructions when possible ([\#9544](matrix-org/matrix-react-sdk#9544)). Contributed by @duxovni.
 * Honor font settings in Element Call ([\#9751](matrix-org/matrix-react-sdk#9751)). Fixes #23661.
 * Device manager - use deleteAccountData to prune device manager client information events ([\#9734](matrix-org/matrix-react-sdk#9734)).

## 🐛 Bug Fixes
 * Display rooms & threads as unread (bold) if threads have unread messages. ([\#9763](matrix-org/matrix-react-sdk#9763)). Fixes #23907.
 * Don't prefer STIXGeneral over the default font ([\#9711](matrix-org/matrix-react-sdk#9711)). Fixes #23899.
 * Use the same avatar colour when creating 1:1 DM rooms ([\#9850](matrix-org/matrix-react-sdk#9850)). Fixes #23476.
 * Fix space lock icon size ([\#9854](matrix-org/matrix-react-sdk#9854)). Fixes #24128.
 * Make calls automatically disconnect if the widget disappears ([\#9862](matrix-org/matrix-react-sdk#9862)). Fixes #23664.
 * Fix emoji in RTE editing ([\#9827](matrix-org/matrix-react-sdk#9827)).
 * Fix export with attachments on formats txt and json ([\#9851](matrix-org/matrix-react-sdk#9851)). Fixes #24130. Contributed by @grimhilt.
 * Fixed empty `Content-Type` for encrypted uploads ([\#9848](matrix-org/matrix-react-sdk#9848)). Contributed by @K3das.
 * Fix sign-in instead link on password reset page ([\#9820](matrix-org/matrix-react-sdk#9820)). Fixes #24087.
 * The seekbar now initially shows the current position ([\#9796](matrix-org/matrix-react-sdk#9796)). Fixes #24051.
 * Fix: Editing a poll will silently change it to a closed poll ([\#9809](matrix-org/matrix-react-sdk#9809)). Fixes #23176.
 * Make call tiles look less broken in the right panel ([\#9808](matrix-org/matrix-react-sdk#9808)). Fixes #23716.
 * Prevent unnecessary m.direct updates ([\#9805](matrix-org/matrix-react-sdk#9805)). Fixes #24059.
 * Fix checkForPreJoinUISI for thread roots ([\#9803](matrix-org/matrix-react-sdk#9803)). Fixes #24054.
 * Snap in PiP widget when content changed ([\#9797](matrix-org/matrix-react-sdk#9797)). Fixes #24050.
 * Load RTE components only when RTE labs is enabled ([\#9804](matrix-org/matrix-react-sdk#9804)).
 * Ensure that events are correctly updated when they are edited. ([\#9789](matrix-org/matrix-react-sdk#9789)).
 * When stopping a broadcast also stop the playback ([\#9795](matrix-org/matrix-react-sdk#9795)). Fixes #24052.
 * Prevent to start two broadcasts at the same time ([\#9744](matrix-org/matrix-react-sdk#9744)). Fixes #23973.
 * Correctly handle limited sync responses by resetting the thread timeline ([\#3056](matrix-org/matrix-js-sdk#3056)). Fixes element-hq/element-web#23952.
 * Fix failure to start in firefox private browser ([\#3058](matrix-org/matrix-js-sdk#3058)). Fixes element-hq/element-web#24216.
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 X-Release-Blocker This affects the current release cycle and must be solved for a release to happen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Messages in threads not marking room as unread
3 participants