From aa7e0249faab3085869f6b5200fb8636f986429f Mon Sep 17 00:00:00 2001 From: dougfabris Date: Tue, 25 May 2021 15:16:22 -0300 Subject: [PATCH] regression: missing room scope on permission --- client/views/room/MemberListRouter.js | 6 +++--- client/views/teams/contextualBar/channels/RoomActions.js | 4 ++-- .../views/teams/contextualBar/channels/TeamsChannelItem.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/views/room/MemberListRouter.js b/client/views/room/MemberListRouter.js index 429109b662e6..980bb8dcc6e3 100644 --- a/client/views/room/MemberListRouter.js +++ b/client/views/room/MemberListRouter.js @@ -7,15 +7,15 @@ import UserInfo from './contextualBar/UserInfo'; import { useTab, useTabBarClose, useTabContext } from './providers/ToolboxProvider'; const getUid = (room, ownUserId) => { - if (room.uids.length === 1) { + if (room.uids?.length === 1) { return room.uids[0]; } - const uid = room.uids.filter((uid) => uid !== ownUserId).shift(); + const uid = room.uids?.filter((uid) => uid !== ownUserId).shift(); // Self DMs used to be created with the userId duplicated. // Sometimes rooms can have 2 equal uids, but it's a self DM. - return uid ?? room.uids[0]; + return uid ? room.uids[0] : undefined; }; const MemberListRouter = ({ rid }) => { diff --git a/client/views/teams/contextualBar/channels/RoomActions.js b/client/views/teams/contextualBar/channels/RoomActions.js index 7b177d6fcf8c..d43b322c894c 100644 --- a/client/views/teams/contextualBar/channels/RoomActions.js +++ b/client/views/teams/contextualBar/channels/RoomActions.js @@ -30,8 +30,8 @@ const RoomActions = ({ room, reload }) => { const dispatchToastMessage = useToastMessageDispatch(); const canDeleteTeamChannel = usePermission(type === 'c' ? 'delete-c' : 'delete-p', rid); - const canEditTeamChannel = usePermission('edit-team-channel'); - const canRemoveTeamChannel = usePermission('remove-team-channel'); + const canEditTeamChannel = usePermission('edit-team-channel', rid); + const canRemoveTeamChannel = usePermission('remove-team-channel', rid); const updateRoomEndpoint = useEndpointActionExperimental('POST', 'teams.updateRoom'); const removeRoomEndpoint = useEndpointActionExperimental( diff --git a/client/views/teams/contextualBar/channels/TeamsChannelItem.js b/client/views/teams/contextualBar/channels/TeamsChannelItem.js index 51e177c16735..a7caaf682de8 100644 --- a/client/views/teams/contextualBar/channels/TeamsChannelItem.js +++ b/client/views/teams/contextualBar/channels/TeamsChannelItem.js @@ -16,8 +16,8 @@ const TeamsChannelItem = ({ room, onClickView, reload }) => { const [showButton, setShowButton] = useState(); - const canRemoveTeamChannel = usePermission('remove-team-channel'); - const canEditTeamChannel = usePermission('edit-team-channel'); + const canRemoveTeamChannel = usePermission('remove-team-channel', rid); + const canEditTeamChannel = usePermission('edit-team-channel', rid); const canDeleteTeamChannel = usePermission(type === 'c' ? 'delete-c' : 'delete-p', rid); const isReduceMotionEnabled = usePrefersReducedMotion();