Run templating on the popout URL too
Fixes https://github.com/vector-im/element-web/issues/15443
This commit is contained in:
parent
2242e6b8c6
commit
3274e2aed5
1 changed files with 25 additions and 17 deletions
|
@ -74,6 +74,16 @@ class ElementWidget extends Widget {
|
||||||
return super.templateUrl;
|
return super.templateUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get popoutTemplateUrl(): string {
|
||||||
|
if (WidgetType.JITSI.matches(this.type)) {
|
||||||
|
return WidgetUtils.getLocalJitsiWrapperUrl({
|
||||||
|
forLocalRender: false, // The only important difference between this and templateUrl()
|
||||||
|
auth: super.rawData?.auth,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return this.templateUrl; // use this instead of super to ensure we get appropriate templating
|
||||||
|
}
|
||||||
|
|
||||||
public get rawData(): IWidgetData {
|
public get rawData(): IWidgetData {
|
||||||
let conferenceId = super.rawData['conferenceId'];
|
let conferenceId = super.rawData['conferenceId'];
|
||||||
if (conferenceId === undefined) {
|
if (conferenceId === undefined) {
|
||||||
|
@ -94,8 +104,8 @@ class ElementWidget extends Widget {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCompleteUrl(params: ITemplateParams): string {
|
public getCompleteUrl(params: ITemplateParams, asPopout=false): string {
|
||||||
return runTemplate(this.templateUrl, {
|
return runTemplate(asPopout ? this.popoutTemplateUrl : this.templateUrl, {
|
||||||
// we need to supply a whole widget to the template, but don't have
|
// we need to supply a whole widget to the template, but don't have
|
||||||
// easy access to the definition the superclass is using, so be sad
|
// easy access to the definition the superclass is using, so be sad
|
||||||
// and gutwrench it.
|
// and gutwrench it.
|
||||||
|
@ -109,7 +119,7 @@ class ElementWidget extends Widget {
|
||||||
|
|
||||||
export class StopGapWidget extends EventEmitter {
|
export class StopGapWidget extends EventEmitter {
|
||||||
private messaging: ClientWidgetApi;
|
private messaging: ClientWidgetApi;
|
||||||
private mockWidget: Widget;
|
private mockWidget: ElementWidget;
|
||||||
private scalarToken: string;
|
private scalarToken: string;
|
||||||
|
|
||||||
constructor(private appTileProps: IAppTileProps) {
|
constructor(private appTileProps: IAppTileProps) {
|
||||||
|
@ -133,12 +143,23 @@ export class StopGapWidget extends EventEmitter {
|
||||||
* The URL to use in the iframe
|
* The URL to use in the iframe
|
||||||
*/
|
*/
|
||||||
public get embedUrl(): string {
|
public get embedUrl(): string {
|
||||||
|
return this.runUrlTemplate({asPopout: false});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URL to use in the popout
|
||||||
|
*/
|
||||||
|
public get popoutUrl(): string {
|
||||||
|
return this.runUrlTemplate({asPopout: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
private runUrlTemplate(opts: {asPopout: boolean} = {asPopout: false}): string {
|
||||||
const templated = this.mockWidget.getCompleteUrl({
|
const templated = this.mockWidget.getCompleteUrl({
|
||||||
currentRoomId: RoomViewStore.getRoomId(),
|
currentRoomId: RoomViewStore.getRoomId(),
|
||||||
currentUserId: MatrixClientPeg.get().getUserId(),
|
currentUserId: MatrixClientPeg.get().getUserId(),
|
||||||
userDisplayName: OwnProfileStore.instance.displayName,
|
userDisplayName: OwnProfileStore.instance.displayName,
|
||||||
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(),
|
userHttpAvatarUrl: OwnProfileStore.instance.getHttpAvatarUrl(),
|
||||||
});
|
}, opts?.asPopout);
|
||||||
|
|
||||||
// Add in some legacy support sprinkles
|
// Add in some legacy support sprinkles
|
||||||
// TODO: Replace these with proper widget params
|
// TODO: Replace these with proper widget params
|
||||||
|
@ -158,19 +179,6 @@ export class StopGapWidget extends EventEmitter {
|
||||||
return parsed.toString().replace(/%24/g, '$');
|
return parsed.toString().replace(/%24/g, '$');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The URL to use in the popout
|
|
||||||
*/
|
|
||||||
public get popoutUrl(): string {
|
|
||||||
if (WidgetType.JITSI.matches(this.mockWidget.type)) {
|
|
||||||
return WidgetUtils.getLocalJitsiWrapperUrl({
|
|
||||||
forLocalRender: false,
|
|
||||||
auth: this.mockWidget.rawData?.auth,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return this.embedUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get isManagedByManager(): boolean {
|
public get isManagedByManager(): boolean {
|
||||||
return !!this.scalarToken;
|
return !!this.scalarToken;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue