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

Show the number of unread notifications above the bell on the right #2336

Merged
merged 2 commits into from
Dec 13, 2018

Conversation

turt2live
Copy link
Member

@turt2live turt2live commented Dec 6, 2018

Requires matrix-org/matrix-js-sdk#802
Fixes element-hq/element-web#3383

This achieves the result by counting up the number of highlights across all rooms and setting that as the badge above the icon. If there are no highlights, nothing is displayed. The red highlight on the bell is done by abusing how the Tinter works: because it has access to the properties of the SVG that we'd need to override it, we give it a collection of colors it should use instead of the theme/tint it is trying to apply. This results in the Tinter using our warning color instead of whatever it was going to apply.

The RightPanel now listens for events to update the count too, otherwise when the user receives a ping they'd have to switch rooms to see the change.

image
Darker color is me testing tinting.

Fixes element-hq/element-web#3383

This achieves the result by counting up the number of highlights across all rooms and setting that as the badge above the icon. If there are no highlights, nothing is displayed. The red highlight on the bell is done by abusing how the Tinter works: because it has access to the properties of the SVG that we'd need to override it, we give it a collection of colors it should use instead of the theme/tint it is trying to apply. This results in the Tinter using our warning color instead of whatever it was going to apply.

The RightPanel now listens for events to update the count too, otherwise when the user receives a ping they'd have to switch rooms to see the change.
@turt2live turt2live requested a review from a team December 6, 2018 23:21
@turt2live
Copy link
Member Author

This has a bug where when reading (or receiving new) notifications the icon doesn't switch colors and remains stuck.

@turt2live turt2live removed the request for review from a team December 6, 2018 23:58
… source

The js-sdk's placement of the notification change was unreliable and could cause stuck notifications. The new location (piggybacking the Notifier) is a lot more reliable.

The tinting has been changed fairly invasively in order to support the changing of the `fill` attribute. What was happening before was the `fill` property would happily get set to the forced color value, but when it came time to reset it it wouldn't be part of the colors array and fail the check, therefore never being changed back. By using a second field we can ensure we are checking the not-forced value where possible, falling back to the potentially forced value if needed. 

In addition to fixing which color the Tinter was checking against, something noticed during development is that `this.colors` might not always be a set of hex color codes. This is problematic when the attribute we're looking to replace is a rgb color code but we're only looking at `keyHex` - the value won't be reset. It appears as though this happens when people use custom tinting in places as `this.colors` often gets set to the rgb values throughout the file. To fix it, we just check against `keyHex` and `keyRgb`.
@turt2live
Copy link
Member Author

Alright, I've fixed this and removed the dependency on the js-sdk for the change. More information about what went wrong is in 95d15b7.

@turt2live turt2live removed the notready label Dec 7, 2018
@turt2live turt2live requested a review from a team December 7, 2018 05:38
if (payload.action === "view_user") {
if (payload.action === "event_notification") {
// Try and re-caclulate any badge counts we might have
this.forceUpdate();
Copy link
Member

Choose a reason for hiding this comment

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

Will you not need an equivalent for when the user reads the notification and the count goes down again?

Copy link
Member Author

Choose a reason for hiding this comment

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

You would think so, but something somewhere magically makes it work. I tested in Chrome and Firefox and for some reason it happily goes down but doesn't magically go up.

Copy link
Member

Choose a reason for hiding this comment

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

yay magic :/

@turt2live turt2live requested a review from a team December 12, 2018 17:05
@turt2live turt2live merged commit 96300b4 into develop Dec 13, 2018
@turt2live turt2live deleted the travis/notif-button branch December 13, 2018 15:17
turt2live added a commit that referenced this pull request Dec 13, 2018
dbkr added a commit that referenced this pull request Jan 3, 2019
Does not include #2336 as the file has been moved out from underneath it:
will do this separately
turt2live added a commit that referenced this pull request Jan 3, 2019
turt2live added a commit that referenced this pull request Jan 3, 2019
Part 2 of 3: Merge develop->experimental minus #2336
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants