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

Mark as Unread #12254

Merged
merged 39 commits into from
Mar 19, 2024
Merged

Mark as Unread #12254

merged 39 commits into from
Mar 19, 2024

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Feb 15, 2024

This implements the 'mark as unread' feature, as per matrix-org/matrix-spec-proposals#2867

Needs matrix-org/matrix-analytics-events#90 (plus release of matrix-analytics-events)

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:

✨ Features

@dbkr dbkr added the T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements label Feb 15, 2024
@dbkr
Copy link
Member Author

dbkr commented Feb 16, 2024

This is now ready, code-wise, just needs a new icon for the mark as unread menu item and whatever testing we want to do before merging.

@dbkr
Copy link
Member Author

dbkr commented Feb 16, 2024

Icon now updated

@dbkr
Copy link
Member Author

dbkr commented Mar 14, 2024

Second split out PR: #12344

thoraj added a commit to verji/matrix-react-sdk that referenced this pull request Mar 15, 2024
* Update `@vector-im/compound-design-tokens` in package.json (matrix-org#12339)

* Change 'type' prop on badges to 'forceDot' (matrix-org#12327)

* Change 'type' prop on badges tio 'forceDot'

Which, hopefully, better represents what it actually does. Tidies
up some of the logic.

Split out from matrix-org#12254

* Missed a file

* More comments

* Oops, there is no count here.

* Back out the logic refactor of StatelessNotificationBadge

because it was also updating the logic for mark as unread badges and
rewriting the ternary to the previous logic would be quite complex.

* Fix doc comment

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Clarify doc on displaying the count

* Update doc for the forceDot param here too.

---------

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* [Backport staging] Update `@vector-im/compound-design-tokens` in package.json (matrix-org#12340)

(cherry picked from commit e3ba643)

Co-authored-by: Florian Duros <florianduros@element.io>

* Fix the image view (matrix-org#12341)

* TAC: Fix hover state when expanded (matrix-org#12337)

* Fix TAC hover state

* Add playwright test

* Update playwright snapshot after last compound style changes

* v3.95.0-rc.0

* v3.95.0

* Reset matrix-js-sdk back to develop branch

* TAC: Order rooms by most recent after notification level (matrix-org#12329)

* Order room by thread timestamp

* Fix key errors in test

* Update jest snapshots

* Update snapshots

* Rename alpha/beta to numbers

* Add playwright test

* Replace forceCount prop with hideIfDot (matrix-org#12344)

This replaces the `forceCount` prop on room badge components with
`hideIfDot` which hopefully gives a better idea of what it does,
since forceCount did not really force a count. Also remove the
prop where it was just passing the default value anyway.

---------

Co-authored-by: Florian Duros <florianduros@element.io>
Co-authored-by: David Baker <dbkr@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: ElementRobot <releases@riot.im>
Co-authored-by: Robin <robin@robin.town>
@dbkr
Copy link
Member Author

dbkr commented Mar 15, 2024

OK, main bits of this now split out & merged separately. The next biggest chunk would be analytics but hopefully this doesn't add a great deal of complexity here.

@dbkr dbkr requested a review from richvdh March 15, 2024 15:56
@@ -102,7 +102,7 @@ export default class NotificationBadge extends React.PureComponent<XOR<IProps, I
if (notification.isIdle && !notification.knocked) return null;
if (hideIfDot && notification.level < NotificationLevel.Notification) {
// This would just be a dot and we've been told not to show dots, so don't show it
if (!notification.hasUnreadCount) return null;
Copy link
Member

Choose a reason for hiding this comment

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

why is it ok/necessary to get rid of this condition?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this probably should have gone when splitting the PR out but I mistakenly left it in. We need to check only the level now because the Mark as Unread badge doesn't have a count but we still want it displayed in this case (it's considered a badge rather than a dot).

test/stores/notifications/RoomNotificationState-test.ts Outdated Show resolved Hide resolved
// * The props force us to, or
// * It's just an activity-level notification or (in theory) lower and the room isn't knocked
const badgeType =
forceDot || (level <= NotificationLevel.Activity && !knocked)
Copy link
Member

Choose a reason for hiding this comment

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

so previously we would show a dot if count was 0 (I think?) but now we will show a badge in this case? I think?

Is that deliberate?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes: because there is no unread message that triggers a notification, the count will be zero for rooms marked as unread, but we still want to display a badge.

playwright/e2e/room_options/marked_unread.spec.ts Outdated Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

code-wise, I think this is ok, but as discussed elsewhere, it seems like there might be be bugs in the impl.

andybalaam pushed a commit that referenced this pull request Mar 18, 2024
* Change 'type' prop on badges tio 'forceDot'

Which, hopefully, better represents what it actually does. Tidies
up some of the logic.

Split out from #12254

* Missed a file

* More comments

* Oops, there is no count here.

* Back out the logic refactor of StatelessNotificationBadge

because it was also updating the logic for mark as unread badges and
rewriting the ternary to the previous logic would be quite complex.

* Fix doc comment

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Clarify doc on displaying the count

* Update doc for the forceDot param here too.

---------

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
@dbkr
Copy link
Member Author

dbkr commented Mar 18, 2024

Thanks. I believe once I saw it mark a room as unread but then fail to update the UI to put the badge on, but all my attempt to repro it subsequently have failed. I'm not really sure how to proceed here. We could go ahead and merge, filing this as a bug so we're aware of it and can chase it later if we get more data, or otherwise perhaps organise another round of testing to see if anyone else can reproduce it?

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

Yeah, I guess let's merge it, and then see if anyone else can repro it.

@dbkr dbkr added this pull request to the merge queue Mar 19, 2024
Merged via the queue into develop with commit a5ed97b Mar 19, 2024
22 checks passed
@dbkr dbkr deleted the dbkr/mark_as_unread branch March 19, 2024 13:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants