Update and expand ways to access pinned messages (#7906)
* Hide pinned messages header button when nothing is pinned Signed-off-by: Robin Townsend <robin@robin.town> * Add pinned messages option to room info panel Signed-off-by: Robin Townsend <robin@robin.town> * Add pinned messages option to room header menu Signed-off-by: Robin Townsend <robin@robin.town> * Make condition more concise Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
parent
33657947d3
commit
464bb727db
6 changed files with 51 additions and 1 deletions
|
@ -36,6 +36,8 @@ import { EchoChamber } from "../../../stores/local-echo/EchoChamber";
|
|||
import { RoomNotifState } from "../../../RoomNotifs";
|
||||
import Modal from "../../../Modal";
|
||||
import ExportDialog from "../dialogs/ExportDialog";
|
||||
import { useSettingValue } from "../../../hooks/useSettings";
|
||||
import { usePinnedEvents } from "../right_panel/PinnedMessagesCard";
|
||||
import RoomViewStore from "../../../stores/RoomViewStore";
|
||||
import { RightPanelPhases } from '../../../stores/right-panel/RightPanelStorePhases';
|
||||
import { ROOM_NOTIFICATIONS_TAB } from "../dialogs/RoomSettingsDialog";
|
||||
|
@ -228,6 +230,29 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
|||
/>;
|
||||
}
|
||||
|
||||
const pinningEnabled = useSettingValue("feature_pinning");
|
||||
const pinCount = usePinnedEvents(pinningEnabled && room)?.length;
|
||||
|
||||
let pinsOption: JSX.Element;
|
||||
if (pinningEnabled) {
|
||||
pinsOption = <IconizedContextMenuOption
|
||||
onClick={(ev: ButtonEvent) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
ensureViewingRoom(ev);
|
||||
RightPanelStore.instance.pushCard({ phase: RightPanelPhases.PinnedMessages }, false);
|
||||
onFinished();
|
||||
}}
|
||||
label={_t("Pinned")}
|
||||
iconClassName="mx_RoomTile_iconPins"
|
||||
>
|
||||
{ pinCount > 0 && <span className="mx_IconizedContextMenu_sublabel">
|
||||
{ pinCount }
|
||||
</span> }
|
||||
</IconizedContextMenuOption>;
|
||||
}
|
||||
|
||||
const onTagRoom = (ev: ButtonEvent, tagId: TagID) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
@ -278,6 +303,8 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
|||
iconClassName="mx_RoomTile_iconFiles"
|
||||
/>
|
||||
|
||||
{ pinsOption }
|
||||
|
||||
<IconizedContextMenuOption
|
||||
onClick={(ev: ButtonEvent) => {
|
||||
ev.preventDefault();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue