Skip to content

Commit c75e5b2

Browse files
committed
Ability to hide pinned messages (element-hq#28183)
Currently, when a room has pinned messages an annoying, impossible to dismiss bar will be displayed over the message area. This patch introduces the following changes: - add a setting to control whether the PinnedMessageBanner is displayed or not (keep current behaviour as default) - add a pin icon to the room header Why allow hiding pinned messages? Because the banner is annoying. I, and judging by the +1s on element-hq#28183 a few other users, found it unnecessary to always have it in front of our eyes. The new setting allows us to make it go away. Why add an icon for pinned messages if you can view pinned messages from room info? I will answer this by posing another question: why display the banner when pinned messages can be viewed from room info? Jokes aside, the icon makes the access quicker--the UX is exactly the same as for threads: you can see then from room info, or by clicking their icon. Fixes element-hq#28183
1 parent b217271 commit c75e5b2

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

src/components/structures/RoomView.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
432432
promptAskToJoin: false,
433433
viewRoomOpts: { buttons: [] },
434434
isRoomEncrypted: null,
435+
showPinnedMessageBanner: SettingsStore.getValue("showPinnedMessageBanner"),
435436
};
436437
}
437438

@@ -2512,7 +2513,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
25122513
<>
25132514
<Measured sensor={this.roomViewBody} onMeasurement={this.onMeasurement} />
25142515
{auxPanel}
2515-
{pinnedMessageBanner}
2516+
{this.state.showPinnedMessageBanner && (pinnedMessageBanner)}
25162517
<main className={timelineClasses}>
25172518
<FileDropTarget parent={this.roomView.current} onFileDrop={this.onFileDrop} />
25182519
{topUnreadMessagesBar}

src/components/views/rooms/RoomHeader/RoomHeader.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import VideoCallIcon from "@vector-im/compound-design-tokens/assets/web/icons/vi
1212
import VoiceCallIcon from "@vector-im/compound-design-tokens/assets/web/icons/voice-call-solid";
1313
import CloseCallIcon from "@vector-im/compound-design-tokens/assets/web/icons/close";
1414
import ThreadsIcon from "@vector-im/compound-design-tokens/assets/web/icons/threads-solid";
15+
import PinIcon from "@vector-im/compound-design-tokens/assets/web/icons/pin-solid";
1516
import RoomInfoIcon from "@vector-im/compound-design-tokens/assets/web/icons/info-solid";
1617
import NotificationsIcon from "@vector-im/compound-design-tokens/assets/web/icons/notifications-solid";
1718
import VerifiedIcon from "@vector-im/compound-design-tokens/assets/web/icons/verified";
@@ -345,6 +346,22 @@ export default function RoomHeader({
345346

346347
{showChatButton && <VideoRoomChatButton room={room} />}
347348

349+
<Tooltip label={_t("right_panel|pinned_messages_button")}>
350+
<IconButton
351+
indicator={notificationLevelToIndicator(threadNotifications)}
352+
onClick={(evt) => {
353+
evt.stopPropagation();
354+
RightPanelStore.instance.showOrHidePhase(RightPanelPhases.PinnedMessages);
355+
// FIXME Track interaction with PinnedMessages
356+
// button?
357+
// PosthogTrackers.trackInteraction("WebRoomHeaderButtonsThreadsButton", evt);
358+
}}
359+
aria-label={_t("right_panel|pinned_messages_button")}
360+
>
361+
<ToggleableIcon Icon={PinIcon} phase={RightPanelPhases.PinnedMessages} />
362+
</IconButton>
363+
</Tooltip>
364+
348365
<Tooltip label={_t("common|threads")}>
349366
<IconButton
350367
indicator={notificationLevelToIndicator(threadNotifications)}

src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
153153
"showTypingNotifications",
154154
"showRedactions",
155155
"showReadReceipts",
156+
"showPinnedMessageBanner",
156157
"showJoinLeaves",
157158
"showDisplaynameChanges",
158159
"showChatEffects",

src/i18n/strings/en_EN.json

+1
Original file line numberDiff line numberDiff line change
@@ -3019,6 +3019,7 @@
30193019
"show_join_leave": "Show join/leave messages (invites/removes/bans unaffected)",
30203020
"show_nsfw_content": "Show NSFW content",
30213021
"show_read_receipts": "Show read receipts sent by other users",
3022+
"show_pinned_message_banner": "Show pinned message banner",
30223023
"show_redaction_placeholder": "Show a placeholder for removed messages",
30233024
"show_stickers_button": "Show stickers button",
30243025
"show_typing_notifications": "Show typing notifications",

src/settings/Settings.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export interface Settings {
235235
"showAvatarChanges": IBaseSetting<boolean>;
236236
"showDisplaynameChanges": IBaseSetting<boolean>;
237237
"showReadReceipts": IBaseSetting<boolean>;
238+
"showPinnedMessageBanner": IBaseSetting<boolean>;
238239
"showTwelveHourTimestamps": IBaseSetting<boolean>;
239240
"alwaysShowTimestamps": IBaseSetting<boolean>;
240241
"userTimezone": IBaseSetting<string>;
@@ -768,6 +769,12 @@ export const SETTINGS: Settings = {
768769
default: true,
769770
invertedSettingName: "hideReadReceipts",
770771
},
772+
"showPinnedMessageBanner": {
773+
supportedLevels: LEVELS_ROOM_SETTINGS,
774+
displayName: _td("settings|show_pinned_message_banner"),
775+
default: true,
776+
invertedSettingName: "hidePinnedMessageBanner",
777+
},
771778
"showTwelveHourTimestamps": {
772779
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
773780
displayName: _td("settings|use_12_hour_format"),

0 commit comments

Comments
 (0)