From e4629878bc97eef029fd33014d6f5ac8e72a1c18 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 2 Feb 2021 14:22:28 +0000 Subject: [PATCH 1/2] Lock widget room ID when added This changes the widget room ID available to widget URL templates so that it's locked to the room the widget was added in. Fixes https://github.com/vector-im/element-web/issues/16337 --- src/components/views/dialogs/ModalWidgetDialog.tsx | 4 ++-- src/stores/ModalWidgetStore.ts | 7 ++++++- src/stores/widgets/StopGapWidget.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/views/dialogs/ModalWidgetDialog.tsx b/src/components/views/dialogs/ModalWidgetDialog.tsx index 484e8f0dcfa..92fb406965b 100644 --- a/src/components/views/dialogs/ModalWidgetDialog.tsx +++ b/src/components/views/dialogs/ModalWidgetDialog.tsx @@ -35,13 +35,13 @@ import { } from "matrix-widget-api"; import {StopGapWidgetDriver} from "../../../stores/widgets/StopGapWidgetDriver"; import {MatrixClientPeg} from "../../../MatrixClientPeg"; -import RoomViewStore from "../../../stores/RoomViewStore"; import {OwnProfileStore} from "../../../stores/OwnProfileStore"; import { arrayFastClone } from "../../../utils/arrays"; import { ElementWidget } from "../../../stores/widgets/StopGapWidget"; interface IProps { widgetDefinition: IModalWidgetOpenRequestData; + widgetRoomId?: string; sourceWidgetId: string; onFinished(success: boolean, data?: IModalWidgetReturnData): void; } @@ -123,7 +123,7 @@ export default class ModalWidgetDialog extends React.PureComponent { return !this.modalInstance; }; - public openModalWidget = (requestData: IModalWidgetOpenRequestData, sourceWidget: Widget) => { + public openModalWidget = ( + requestData: IModalWidgetOpenRequestData, + sourceWidget: Widget, + widgetRoomId?: string, + ) => { if (this.modalInstance) return; this.openSourceWidgetId = sourceWidget.id; this.modalInstance = Modal.createTrackedDialog('Modal Widget', '', ModalWidgetDialog, { widgetDefinition: {...requestData}, + widgetRoomId, sourceWidgetId: sourceWidget.id, onFinished: (success: boolean, data?: IModalWidgetReturnData) => { if (!success) { diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index cc2934aec1e..17371d6d458 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -190,7 +190,7 @@ export class StopGapWidget extends EventEmitter { private runUrlTemplate(opts = {asPopout: false}): string { const templated = this.mockWidget.getCompleteUrl({ - currentRoomId: RoomViewStore.getRoomId(), + widgetRoomId: this.roomId, currentUserId: MatrixClientPeg.get().getUserId(), userDisplayName: OwnProfileStore.instance.displayName, userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(), From f53e7039939f633a86d09c7570f49c2aab5d0449 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 2 Feb 2021 14:42:10 +0000 Subject: [PATCH 2/2] Upgrade matrix-widget-api --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 014cee02aa2..d484774aeaf 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "linkifyjs": "^2.1.9", "lodash": "^4.17.20", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", - "matrix-widget-api": "^0.1.0-beta.12", + "matrix-widget-api": "^0.1.0-beta.13", "minimist": "^1.2.5", "pako": "^2.0.3", "parse5": "^6.0.1", diff --git a/yarn.lock b/yarn.lock index 83a708f510a..6419d68b134 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5604,10 +5604,10 @@ matrix-react-test-utils@^0.2.2: resolved "https://registry.yarnpkg.com/matrix-react-test-utils/-/matrix-react-test-utils-0.2.2.tgz#c87144d3b910c7edc544a6699d13c7c2bf02f853" integrity sha512-49+7gfV6smvBIVbeloql+37IeWMTD+fiywalwCqk8Dnz53zAFjKSltB3rmWHso1uecLtQEcPtCijfhzcLXAxTQ== -matrix-widget-api@^0.1.0-beta.12: - version "0.1.0-beta.12" - resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.12.tgz#6cadeabde14f02949b7c3177434a4755942559b8" - integrity sha512-43xVAzLYzddYF73r6NK7NZ3geDLshQqCNAAcv0t5LFyFkKYGWDQG/cg8Vn8d37wm9WVBqYZUOXy9vBD4JcWVPA== +matrix-widget-api@^0.1.0-beta.13: + version "0.1.0-beta.13" + resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-0.1.0-beta.13.tgz#ebddc83eaef39bbb87b621a02a35902e1a29b9ef" + integrity sha512-DJAvuX2E7gxc/a9rtJPDh17ba9xGIOAoBHcWirNTN3KGodzsrZ+Ns+M/BREFWMwGS5yEBZko5eq7uhXStEbnyQ== dependencies: "@types/events" "^3.0.0" events "^3.2.0"