You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-08 21:42:24 +03:00
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
This commit is contained in:
@@ -35,13 +35,13 @@ import {
|
|||||||
} from "matrix-widget-api";
|
} from "matrix-widget-api";
|
||||||
import {StopGapWidgetDriver} from "../../../stores/widgets/StopGapWidgetDriver";
|
import {StopGapWidgetDriver} from "../../../stores/widgets/StopGapWidgetDriver";
|
||||||
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
||||||
import RoomViewStore from "../../../stores/RoomViewStore";
|
|
||||||
import {OwnProfileStore} from "../../../stores/OwnProfileStore";
|
import {OwnProfileStore} from "../../../stores/OwnProfileStore";
|
||||||
import { arrayFastClone } from "../../../utils/arrays";
|
import { arrayFastClone } from "../../../utils/arrays";
|
||||||
import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
|
import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
widgetDefinition: IModalWidgetOpenRequestData;
|
widgetDefinition: IModalWidgetOpenRequestData;
|
||||||
|
widgetRoomId?: string;
|
||||||
sourceWidgetId: string;
|
sourceWidgetId: string;
|
||||||
onFinished(success: boolean, data?: IModalWidgetReturnData): void;
|
onFinished(success: boolean, data?: IModalWidgetReturnData): void;
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
|
|||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const templated = this.widget.getCompleteUrl({
|
const templated = this.widget.getCompleteUrl({
|
||||||
currentRoomId: RoomViewStore.getRoomId(),
|
widgetRoomId: this.props.widgetRoomId,
|
||||||
currentUserId: MatrixClientPeg.get().getUserId(),
|
currentUserId: MatrixClientPeg.get().getUserId(),
|
||||||
userDisplayName: OwnProfileStore.instance.displayName,
|
userDisplayName: OwnProfileStore.instance.displayName,
|
||||||
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(),
|
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(),
|
||||||
|
|||||||
@@ -48,11 +48,16 @@ export class ModalWidgetStore extends AsyncStoreWithClient<IState> {
|
|||||||
return !this.modalInstance;
|
return !this.modalInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
public openModalWidget = (requestData: IModalWidgetOpenRequestData, sourceWidget: Widget) => {
|
public openModalWidget = (
|
||||||
|
requestData: IModalWidgetOpenRequestData,
|
||||||
|
sourceWidget: Widget,
|
||||||
|
widgetRoomId?: string,
|
||||||
|
) => {
|
||||||
if (this.modalInstance) return;
|
if (this.modalInstance) return;
|
||||||
this.openSourceWidgetId = sourceWidget.id;
|
this.openSourceWidgetId = sourceWidget.id;
|
||||||
this.modalInstance = Modal.createTrackedDialog('Modal Widget', '', ModalWidgetDialog, {
|
this.modalInstance = Modal.createTrackedDialog('Modal Widget', '', ModalWidgetDialog, {
|
||||||
widgetDefinition: {...requestData},
|
widgetDefinition: {...requestData},
|
||||||
|
widgetRoomId,
|
||||||
sourceWidgetId: sourceWidget.id,
|
sourceWidgetId: sourceWidget.id,
|
||||||
onFinished: (success: boolean, data?: IModalWidgetReturnData) => {
|
onFinished: (success: boolean, data?: IModalWidgetReturnData) => {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ export class StopGapWidget extends EventEmitter {
|
|||||||
|
|
||||||
private runUrlTemplate(opts = {asPopout: false}): string {
|
private runUrlTemplate(opts = {asPopout: false}): string {
|
||||||
const templated = this.mockWidget.getCompleteUrl({
|
const templated = this.mockWidget.getCompleteUrl({
|
||||||
currentRoomId: RoomViewStore.getRoomId(),
|
widgetRoomId: this.roomId,
|
||||||
currentUserId: MatrixClientPeg.get().getUserId(),
|
currentUserId: MatrixClientPeg.get().getUserId(),
|
||||||
userDisplayName: OwnProfileStore.instance.displayName,
|
userDisplayName: OwnProfileStore.instance.displayName,
|
||||||
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(),
|
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(),
|
||||||
|
|||||||
Reference in New Issue
Block a user