From da93be467731f8cb518f7d339642095e4a38c6ad Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 16 Oct 2020 11:51:27 +0100 Subject: [PATCH] Iterate Widget Context Menu Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/context_menus/WidgetContextMenu.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/views/context_menus/WidgetContextMenu.tsx b/src/components/views/context_menus/WidgetContextMenu.tsx index 44cdc5523e..7656e70341 100644 --- a/src/components/views/context_menus/WidgetContextMenu.tsx +++ b/src/components/views/context_menus/WidgetContextMenu.tsx @@ -30,6 +30,7 @@ import {SettingLevel} from "../../../settings/SettingLevel"; import Modal from "../../../Modal"; import QuestionDialog from "../dialogs/QuestionDialog"; import {WidgetType} from "../../../widgets/WidgetType"; +import MatrixClientContext from "../../../contexts/MatrixClientContext"; interface IProps extends React.ComponentProps { app: IApp; @@ -47,6 +48,7 @@ const WidgetContextMenu: React.FC = ({ showUnpin, ...props }) => { + const cli = useContext(MatrixClientContext); const {room, roomId} = useContext(RoomContext); const widgetMessaging = WidgetMessagingStore.instance.getMessagingForId(app.id); @@ -113,9 +115,14 @@ const WidgetContextMenu: React.FC = ({ />; } + let isAllowedWidget = SettingsStore.getValue("allowedWidgets", roomId)[app.eventId]; + if (isAllowedWidget === undefined) { + isAllowedWidget = app.creatorUserId === cli.getUserId(); + } + const isLocalWidget = WidgetType.JITSI.matches(app.type); let revokeButton; - if (!userWidget && !isLocalWidget) { + if (!userWidget && !isLocalWidget && isAllowedWidget) { const onRevokeClick = () => { console.info("Revoking permission for widget to load: " + app.eventId); const current = SettingsStore.getValue("allowedWidgets", roomId); @@ -127,7 +134,7 @@ const WidgetContextMenu: React.FC = ({ onFinished(); }; - revokeButton = ; + revokeButton = ; } const pinnedWidgets = WidgetStore.instance.getPinnedApps(roomId);