Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 4abe043

Browse files
committed
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 element-hq/element-web#16337
1 parent 132057d commit 4abe043

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/components/views/dialogs/ModalWidgetDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
4242

4343
interface IProps {
4444
widgetDefinition: IModalWidgetOpenRequestData;
45+
widgetRoomId?: string;
4546
sourceWidgetId: string;
4647
onFinished(success: boolean, data?: IModalWidgetReturnData): void;
4748
}
@@ -123,7 +124,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
123124

124125
public render() {
125126
const templated = this.widget.getCompleteUrl({
126-
currentRoomId: RoomViewStore.getRoomId(),
127+
widgetRoomId: this.props.widgetRoomId,
127128
currentUserId: MatrixClientPeg.get().getUserId(),
128129
userDisplayName: OwnProfileStore.instance.displayName,
129130
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(),

src/stores/ModalWidgetStore.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ export class ModalWidgetStore extends AsyncStoreWithClient<IState> {
4848
return !this.modalInstance;
4949
};
5050

51-
public openModalWidget = (requestData: IModalWidgetOpenRequestData, sourceWidget: Widget) => {
51+
public openModalWidget = (
52+
requestData: IModalWidgetOpenRequestData,
53+
sourceWidget: Widget,
54+
widgetRoomId?: string,
55+
) => {
5256
if (this.modalInstance) return;
5357
this.openSourceWidgetId = sourceWidget.id;
5458
this.modalInstance = Modal.createTrackedDialog('Modal Widget', '', ModalWidgetDialog, {
5559
widgetDefinition: {...requestData},
60+
widgetRoomId,
5661
sourceWidgetId: sourceWidget.id,
5762
onFinished: (success: boolean, data?: IModalWidgetReturnData) => {
5863
if (!success) {

src/stores/widgets/StopGapWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class StopGapWidget extends EventEmitter {
190190

191191
private runUrlTemplate(opts = {asPopout: false}): string {
192192
const templated = this.mockWidget.getCompleteUrl({
193-
currentRoomId: RoomViewStore.getRoomId(),
193+
widgetRoomId: this.roomId,
194194
currentUserId: MatrixClientPeg.get().getUserId(),
195195
userDisplayName: OwnProfileStore.instance.displayName,
196196
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(),

0 commit comments

Comments
 (0)