mirror of https://github.com/vector-im/riot-web
Iterate Widget Context Menu
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
efbce309d0
commit
da93be4677
|
@ -30,6 +30,7 @@ import {SettingLevel} from "../../../settings/SettingLevel";
|
||||||
import Modal from "../../../Modal";
|
import Modal from "../../../Modal";
|
||||||
import QuestionDialog from "../dialogs/QuestionDialog";
|
import QuestionDialog from "../dialogs/QuestionDialog";
|
||||||
import {WidgetType} from "../../../widgets/WidgetType";
|
import {WidgetType} from "../../../widgets/WidgetType";
|
||||||
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||||
|
|
||||||
interface IProps extends React.ComponentProps<typeof IconizedContextMenu> {
|
interface IProps extends React.ComponentProps<typeof IconizedContextMenu> {
|
||||||
app: IApp;
|
app: IApp;
|
||||||
|
@ -47,6 +48,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
||||||
showUnpin,
|
showUnpin,
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
|
const cli = useContext(MatrixClientContext);
|
||||||
const {room, roomId} = useContext(RoomContext);
|
const {room, roomId} = useContext(RoomContext);
|
||||||
|
|
||||||
const widgetMessaging = WidgetMessagingStore.instance.getMessagingForId(app.id);
|
const widgetMessaging = WidgetMessagingStore.instance.getMessagingForId(app.id);
|
||||||
|
@ -113,9 +115,14 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isAllowedWidget = SettingsStore.getValue("allowedWidgets", roomId)[app.eventId];
|
||||||
|
if (isAllowedWidget === undefined) {
|
||||||
|
isAllowedWidget = app.creatorUserId === cli.getUserId();
|
||||||
|
}
|
||||||
|
|
||||||
const isLocalWidget = WidgetType.JITSI.matches(app.type);
|
const isLocalWidget = WidgetType.JITSI.matches(app.type);
|
||||||
let revokeButton;
|
let revokeButton;
|
||||||
if (!userWidget && !isLocalWidget) {
|
if (!userWidget && !isLocalWidget && isAllowedWidget) {
|
||||||
const onRevokeClick = () => {
|
const onRevokeClick = () => {
|
||||||
console.info("Revoking permission for widget to load: " + app.eventId);
|
console.info("Revoking permission for widget to load: " + app.eventId);
|
||||||
const current = SettingsStore.getValue("allowedWidgets", roomId);
|
const current = SettingsStore.getValue("allowedWidgets", roomId);
|
||||||
|
@ -127,7 +134,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
|
||||||
onFinished();
|
onFinished();
|
||||||
};
|
};
|
||||||
|
|
||||||
revokeButton = <IconizedContextMenuOption onClick={onRevokeClick} label={_t("Remove for me")} />;
|
revokeButton = <IconizedContextMenuOption onClick={onRevokeClick} label={_t("Revoke permissions")} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pinnedWidgets = WidgetStore.instance.getPinnedApps(roomId);
|
const pinnedWidgets = WidgetStore.instance.getPinnedApps(roomId);
|
||||||
|
|
Loading…
Reference in New Issue