mirror of https://github.com/vector-im/riot-web
Iterate room context menus for DMs (#7308)
parent
e0162d255e
commit
9452a3cc09
|
@ -44,6 +44,7 @@ import { Action } from "../../../dispatcher/actions";
|
||||||
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
|
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
|
||||||
import { ROOM_NOTIFICATIONS_TAB } from "../dialogs/RoomSettingsDialog";
|
import { ROOM_NOTIFICATIONS_TAB } from "../dialogs/RoomSettingsDialog";
|
||||||
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
|
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
|
||||||
|
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||||
|
|
||||||
interface IProps extends IContextMenuProps {
|
interface IProps extends IContextMenuProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
|
@ -96,8 +97,10 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isDm = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
||||||
|
|
||||||
let inviteOption: JSX.Element;
|
let inviteOption: JSX.Element;
|
||||||
if (room.canInvite(cli.getUserId())) {
|
if (room.canInvite(cli.getUserId()) && !isDm) {
|
||||||
const onInviteClick = (ev: ButtonEvent) => {
|
const onInviteClick = (ev: ButtonEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
@ -179,6 +182,42 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
||||||
</IconizedContextMenuOption>;
|
</IconizedContextMenuOption>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let peopleOption: JSX.Element;
|
||||||
|
let copyLinkOption: JSX.Element;
|
||||||
|
if (!isDm) {
|
||||||
|
peopleOption = <IconizedContextMenuOption
|
||||||
|
onClick={(ev: ButtonEvent) => {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
|
ensureViewingRoom();
|
||||||
|
onRoomMembersClick(false);
|
||||||
|
onFinished();
|
||||||
|
}}
|
||||||
|
label={_t("People")}
|
||||||
|
iconClassName="mx_RoomTile_iconPeople"
|
||||||
|
>
|
||||||
|
<span className="mx_IconizedContextMenu_sublabel">
|
||||||
|
{ room.getJoinedMemberCount() }
|
||||||
|
</span>
|
||||||
|
</IconizedContextMenuOption>;
|
||||||
|
|
||||||
|
copyLinkOption = <IconizedContextMenuOption
|
||||||
|
onClick={(ev: ButtonEvent) => {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
|
dis.dispatch({
|
||||||
|
action: "copy_room",
|
||||||
|
room_id: room.roomId,
|
||||||
|
});
|
||||||
|
onFinished();
|
||||||
|
}}
|
||||||
|
label={_t("Copy link")}
|
||||||
|
iconClassName="mx_RoomTile_iconCopyLink"
|
||||||
|
/>;
|
||||||
|
}
|
||||||
|
|
||||||
const onTagRoom = (ev: ButtonEvent, tagId: TagID) => {
|
const onTagRoom = (ev: ButtonEvent, tagId: TagID) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
@ -212,23 +251,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
||||||
{ inviteOption }
|
{ inviteOption }
|
||||||
{ notificationOption }
|
{ notificationOption }
|
||||||
{ favouriteOption }
|
{ favouriteOption }
|
||||||
|
{ peopleOption }
|
||||||
<IconizedContextMenuOption
|
|
||||||
onClick={(ev: ButtonEvent) => {
|
|
||||||
ev.preventDefault();
|
|
||||||
ev.stopPropagation();
|
|
||||||
|
|
||||||
ensureViewingRoom();
|
|
||||||
onRoomMembersClick(false);
|
|
||||||
onFinished();
|
|
||||||
}}
|
|
||||||
label={_t("People")}
|
|
||||||
iconClassName="mx_RoomTile_iconPeople"
|
|
||||||
>
|
|
||||||
<span className="mx_IconizedContextMenu_sublabel">
|
|
||||||
{ room.getJoinedMemberCount() }
|
|
||||||
</span>
|
|
||||||
</IconizedContextMenuOption>
|
|
||||||
|
|
||||||
<IconizedContextMenuOption
|
<IconizedContextMenuOption
|
||||||
onClick={(ev: ButtonEvent) => {
|
onClick={(ev: ButtonEvent) => {
|
||||||
|
@ -261,21 +284,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{ lowPriorityOption }
|
{ lowPriorityOption }
|
||||||
|
{ copyLinkOption }
|
||||||
<IconizedContextMenuOption
|
|
||||||
onClick={(ev: ButtonEvent) => {
|
|
||||||
ev.preventDefault();
|
|
||||||
ev.stopPropagation();
|
|
||||||
|
|
||||||
dis.dispatch({
|
|
||||||
action: "copy_room",
|
|
||||||
room_id: room.roomId,
|
|
||||||
});
|
|
||||||
onFinished();
|
|
||||||
}}
|
|
||||||
label={_t("Copy link")}
|
|
||||||
iconClassName="mx_RoomTile_iconCopyLink"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<IconizedContextMenuOption
|
<IconizedContextMenuOption
|
||||||
onClick={(ev: ButtonEvent) => {
|
onClick={(ev: ButtonEvent) => {
|
||||||
|
|
|
@ -485,8 +485,10 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
const isLowPriority = roomTags.includes(DefaultTagID.LowPriority);
|
const isLowPriority = roomTags.includes(DefaultTagID.LowPriority);
|
||||||
const lowPriorityLabel = _t("Low Priority");
|
const lowPriorityLabel = _t("Low Priority");
|
||||||
|
|
||||||
|
const isDm = roomTags.includes(DefaultTagID.DM);
|
||||||
|
|
||||||
const userId = MatrixClientPeg.get().getUserId();
|
const userId = MatrixClientPeg.get().getUserId();
|
||||||
const canInvite = this.props.room.canInvite(userId);
|
const canInvite = this.props.room.canInvite(userId) && !isDm; // hide invite in DMs from this quick menu
|
||||||
contextMenu = <IconizedContextMenu
|
contextMenu = <IconizedContextMenu
|
||||||
{...contextMenuBelow(this.state.generalMenuPosition)}
|
{...contextMenuBelow(this.state.generalMenuPosition)}
|
||||||
onFinished={this.onCloseGeneralMenu}
|
onFinished={this.onCloseGeneralMenu}
|
||||||
|
@ -513,11 +515,11 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
iconClassName="mx_RoomTile_iconInvite"
|
iconClassName="mx_RoomTile_iconInvite"
|
||||||
/>
|
/>
|
||||||
) : null }
|
) : null }
|
||||||
<IconizedContextMenuOption
|
{ !isDm ? <IconizedContextMenuOption
|
||||||
onClick={this.onCopyRoomClick}
|
onClick={this.onCopyRoomClick}
|
||||||
label={_t("Copy Room Link")}
|
label={_t("Copy Room Link")}
|
||||||
iconClassName="mx_RoomTile_iconCopyLink"
|
iconClassName="mx_RoomTile_iconCopyLink"
|
||||||
/>
|
/> : null }
|
||||||
<IconizedContextMenuOption
|
<IconizedContextMenuOption
|
||||||
onClick={this.onOpenRoomSettings}
|
onClick={this.onOpenRoomSettings}
|
||||||
label={_t("Settings")}
|
label={_t("Settings")}
|
||||||
|
|
Loading…
Reference in New Issue