This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 832
Display rooms & threads as unread (bold) if threads have unread messages. #9763
Merged
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
511fbd7
Display rooms as unread (bold) if threads have unread messages.
clokep ad4feef
Display threads in the threads list as unread (bold).
clokep 82fdbac
Add a badge to the threads icon if any threads are unread.
clokep 06c6a5f
Merge remote-tracking branch 'upstream/develop' into unread-threads
clokep c324fe7
Merge remote-tracking branch 'upstream/develop' into unread-threads
clokep b8a42ca
Add an extra check for uninitialized timelines.
clokep 2daf604
Attempt to appease linter.
clokep 8e7dc94
More linting fixes.
clokep 22afd72
Rename variable.
clokep 5ca3fe1
Fix tests.
clokep 3ef2830
Merge remote-tracking branch 'upstream/develop' into unread-threads
clokep 771d6da
Update tests
germain-gg dd1fe22
Merge branch 'develop' into unread-threads
a92e181
Merge branch 'develop' into unread-threads
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,6 +21,7 @@ limitations under the License. | |||||||||||||||||||||||||||||
import React from "react"; | ||||||||||||||||||||||||||||||
import classNames from "classnames"; | ||||||||||||||||||||||||||||||
import { NotificationCountType, Room, RoomEvent } from "matrix-js-sdk/src/models/room"; | ||||||||||||||||||||||||||||||
import { ThreadEvent } from "matrix-js-sdk/src/models/thread"; | ||||||||||||||||||||||||||||||
import { Feature, ServerSupport } from "matrix-js-sdk/src/feature"; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
import { _t } from "../../../languageHandler"; | ||||||||||||||||||||||||||||||
|
@@ -44,6 +45,7 @@ import { NotificationStateEvents } from "../../../stores/notifications/Notificat | |||||||||||||||||||||||||||||
import PosthogTrackers from "../../../PosthogTrackers"; | ||||||||||||||||||||||||||||||
import { ButtonEvent } from "../elements/AccessibleButton"; | ||||||||||||||||||||||||||||||
import { MatrixClientPeg } from "../../../MatrixClientPeg"; | ||||||||||||||||||||||||||||||
import { doesRoomOrThreadHaveUnreadMessages } from "../../../Unread"; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
const ROOM_INFO_PHASES = [ | ||||||||||||||||||||||||||||||
RightPanelPhases.RoomSummary, | ||||||||||||||||||||||||||||||
|
@@ -154,7 +156,17 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> { | |||||||||||||||||||||||||||||
if (!this.supportsThreadNotifications) { | ||||||||||||||||||||||||||||||
this.threadNotificationState?.on(NotificationStateEvents.Update, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||
// 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); | ||||||||||||||||||||||||||||||
Comment on lines
+159
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are mostly copied from matrix-react-sdk/src/hooks/useUnreadNotifications.ts Lines 40 to 53 in ad4feef
|
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
this.onNotificationUpdate(); | ||||||||||||||||||||||||||||||
RoomNotificationStateStore.instance.on(UPDATE_STATUS_INDICATOR, this.onUpdateStatus); | ||||||||||||||||||||||||||||||
|
@@ -166,6 +178,13 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> { | |||||||||||||||||||||||||||||
this.threadNotificationState?.off(NotificationStateEvents.Update, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||
this.props.room?.off(RoomEvent.UnreadNotifications, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
this.props.room?.off(RoomEvent.Receipt, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
this.props.room?.off(RoomEvent.Timeline, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
this.props.room?.off(RoomEvent.Redaction, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
this.props.room?.off(RoomEvent.LocalEchoUpdated, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
this.props.room?.off(RoomEvent.MyMembership, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
this.props.room?.off(ThreadEvent.New, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
this.props.room?.off(ThreadEvent.Update, this.onNotificationUpdate); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
RoomNotificationStateStore.instance.off(UPDATE_STATUS_INDICATOR, this.onUpdateStatus); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
@@ -191,9 +210,17 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> { | |||||||||||||||||||||||||||||
return NotificationColor.Red; | ||||||||||||||||||||||||||||||
case NotificationCountType.Total: | ||||||||||||||||||||||||||||||
return NotificationColor.Grey; | ||||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||||
return NotificationColor.None; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
// We don't have any notified messages, but we might have unread messages. Let's | ||||||||||||||||||||||||||||||
// find out. | ||||||||||||||||||||||||||||||
for (const thread of this.props.room!.getThreads()) { | ||||||||||||||||||||||||||||||
// If the current thread has unread messages, we're done. | ||||||||||||||||||||||||||||||
if (doesRoomOrThreadHaveUnreadMessages(thread)) { | ||||||||||||||||||||||||||||||
return NotificationColor.Bold; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
// Otherwise, no notification color. | ||||||||||||||||||||||||||||||
return NotificationColor.None; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
private onUpdateStatus = (notificationState: SummarizedNotificationState): void => { | ||||||||||||||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we compare "when" this way? Using the
ts
of the receipt and theorigin_server_ts
of the events?There was a problem hiding this comment.
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#3020matrix-org/matrix-js-sdk#3031, although we might need more tweaks here.