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

Improve pinned messages in Labs #6096

Merged
merged 21 commits into from
Jun 3, 2021
Merged

Improve pinned messages in Labs #6096

merged 21 commits into from
Jun 3, 2021

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented May 25, 2021

Fixes element-hq/element-web#5405
Fixes element-hq/element-web#5958
Fixes element-hq/element-web#5871
Fixes element-hq/element-web#17213
Fixes element-hq/element-web#6926

Screen.Recording.2021-05-26.at.15.20.12.mov

image

Skipping design/product as it isn't leaving Labs yet

@t3chguy t3chguy requested a review from a team May 26, 2021 14:23
@t3chguy t3chguy marked this pull request as ready for review May 26, 2021 14:23
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

overall seems fine, just a few comments relating to code style and a behavioural thing.

There's also a few mixed cases of {words} and { words }, which I believe is a lint rule applied after this PR was introduced: would be good to normalize before landing.

@@ -1,5 +1,5 @@
/*
Copyright 2017 Travis Ralston
Copyright 2021 The Matrix.org Foundation C.I.C.
Copy link
Member

Choose a reason for hiding this comment

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

goodbye, self.

(I'm okay with this happening - I don't want any of the old CSS associated with my name)

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 mean, there is no old CSS here. All of it is brand new, I probably renamed the file to save me having to copy-paste the license :)

src/components/structures/NotificationPanel.tsx Outdated Show resolved Hide resolved
src/components/structures/RightPanel.tsx Outdated Show resolved Hide resolved
Comment on lines +46 to +49
const pinningEnabled = useSettingValue("feature_pinning");
const pinnedEvents = usePinnedEvents(pinningEnabled && room);
const readPinnedEvents = useReadPinnedEvents(pinningEnabled && room);
if (!pinningEnabled) 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.

we can probably short circuit this by not reading pinned events if the setting isn't enabled. ie: move new lines 47 and 48 to below this condition:

Suggested change
const pinningEnabled = useSettingValue("feature_pinning");
const pinnedEvents = usePinnedEvents(pinningEnabled && room);
const readPinnedEvents = useReadPinnedEvents(pinningEnabled && room);
if (!pinningEnabled) return null;
const pinningEnabled = useSettingValue("feature_pinning");
if (!pinningEnabled) return null;
const pinnedEvents = usePinnedEvents(pinningEnabled && room);
const readPinnedEvents = useReadPinnedEvents(pinningEnabled && room);

Copy link
Member Author

Choose a reason for hiding this comment

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

Hooks cannot be conditional.
But the two hooks here are effectively no-opd if you pass them a falsey as we are here.

The alternative would be tracking feature_pinning in RoomHeaderButtons but that's more lines of code due to the class setup than a useSettingValue hook call

Copy link
Member

Choose a reason for hiding this comment

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

well that's not very fun :(

This is fine, then.

src/components/views/rooms/PinnedEventTile.tsx Outdated Show resolved Hide resolved
t3chguy and others added 5 commits June 3, 2021 08:03
Co-authored-by: Travis Ralston <travisr@matrix.org>
… t3chguy/fix/6606

� Conflicts:
�	src/components/structures/RoomView.tsx
�	src/components/views/right_panel/UserInfo.tsx
@t3chguy t3chguy requested a review from turt2live June 3, 2021 07:43
@t3chguy t3chguy merged commit f22fd7a into develop Jun 3, 2021
@t3chguy t3chguy deleted the t3chguy/fix/6606 branch June 3, 2021 23:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.