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 { ROOM_NOTIFICATIONS_TAB } from "../dialogs/RoomSettingsDialog"; | ||||
| import { useEventEmitterState } from "../../../hooks/useEventEmitter"; | ||||
| import DMRoomMap from "../../../utils/DMRoomMap"; | ||||
| 
 | ||||
| interface IProps extends IContextMenuProps { | ||||
|     room: Room; | ||||
|  | @ -96,8 +97,10 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => { | |||
|         />; | ||||
|     } | ||||
| 
 | ||||
|     const isDm = DMRoomMap.shared().getUserIdForRoomId(room.roomId); | ||||
| 
 | ||||
|     let inviteOption: JSX.Element; | ||||
|     if (room.canInvite(cli.getUserId())) { | ||||
|     if (room.canInvite(cli.getUserId()) && !isDm) { | ||||
|         const onInviteClick = (ev: ButtonEvent) => { | ||||
|             ev.preventDefault(); | ||||
|             ev.stopPropagation(); | ||||
|  | @ -179,6 +182,42 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => { | |||
|         </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) => { | ||||
|         ev.preventDefault(); | ||||
|         ev.stopPropagation(); | ||||
|  | @ -212,23 +251,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => { | |||
|             { inviteOption } | ||||
|             { notificationOption } | ||||
|             { favouriteOption } | ||||
| 
 | ||||
|             <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> | ||||
|             { peopleOption } | ||||
| 
 | ||||
|             <IconizedContextMenuOption | ||||
|                 onClick={(ev: ButtonEvent) => { | ||||
|  | @ -261,21 +284,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => { | |||
|             /> | ||||
| 
 | ||||
|             { lowPriorityOption } | ||||
| 
 | ||||
|             <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" | ||||
|             /> | ||||
|             { copyLinkOption } | ||||
| 
 | ||||
|             <IconizedContextMenuOption | ||||
|                 onClick={(ev: ButtonEvent) => { | ||||
|  |  | |||
|  | @ -485,8 +485,10 @@ export default class RoomTile extends React.PureComponent<IProps, IState> { | |||
|             const isLowPriority = roomTags.includes(DefaultTagID.LowPriority); | ||||
|             const lowPriorityLabel = _t("Low Priority"); | ||||
| 
 | ||||
|             const isDm = roomTags.includes(DefaultTagID.DM); | ||||
| 
 | ||||
|             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 | ||||
|                 {...contextMenuBelow(this.state.generalMenuPosition)} | ||||
|                 onFinished={this.onCloseGeneralMenu} | ||||
|  | @ -513,11 +515,11 @@ export default class RoomTile extends React.PureComponent<IProps, IState> { | |||
|                             iconClassName="mx_RoomTile_iconInvite" | ||||
|                         /> | ||||
|                     ) : null } | ||||
|                     <IconizedContextMenuOption | ||||
|                     { !isDm ? <IconizedContextMenuOption | ||||
|                         onClick={this.onCopyRoomClick} | ||||
|                         label={_t("Copy Room Link")} | ||||
|                         iconClassName="mx_RoomTile_iconCopyLink" | ||||
|                     /> | ||||
|                     /> : null } | ||||
|                     <IconizedContextMenuOption | ||||
|                         onClick={this.onOpenRoomSettings} | ||||
|                         label={_t("Settings")} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Michael Telatynski
						Michael Telatynski