mirror of https://github.com/vector-im/riot-web
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/feat/widgets
Conflicts: res/css/views/rooms/_AppsDrawer.scss src/components/views/elements/AppTile.js src/components/views/rooms/AppsDrawer.jspull/21833/head
commit
d36fafd0c6
|
@ -201,10 +201,14 @@ export default class AppTile extends React.Component {
|
||||||
this.iframe.src = 'about:blank';
|
this.iframe.src = 'about:blank';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (WidgetType.JITSI.matches(this.props.app.type)) {
|
||||||
|
dis.dispatch({action: 'hangup_conference'});
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the widget from the persisted store for good measure.
|
// Delete the widget from the persisted store for good measure.
|
||||||
PersistedElement.destroyElement(this._persistKey);
|
PersistedElement.destroyElement(this._persistKey);
|
||||||
|
|
||||||
this._sgWidget.stop();
|
this._sgWidget.stop({forceDestroy: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onWidgetPrepared = () => {
|
_onWidgetPrepared = () => {
|
||||||
|
|
|
@ -58,6 +58,11 @@ export default class PersistentApp extends React.Component {
|
||||||
const persistentWidgetInRoomId = ActiveWidgetStore.getRoomId(this.state.persistentWidgetId);
|
const persistentWidgetInRoomId = ActiveWidgetStore.getRoomId(this.state.persistentWidgetId);
|
||||||
if (this.state.roomId !== persistentWidgetInRoomId) {
|
if (this.state.roomId !== persistentWidgetInRoomId) {
|
||||||
const persistentWidgetInRoom = MatrixClientPeg.get().getRoom(persistentWidgetInRoomId);
|
const persistentWidgetInRoom = MatrixClientPeg.get().getRoom(persistentWidgetInRoomId);
|
||||||
|
|
||||||
|
// Sanity check the room - the widget may have been destroyed between render cycles, and
|
||||||
|
// thus no room is associated anymore.
|
||||||
|
if (!persistentWidgetInRoom) return null;
|
||||||
|
|
||||||
// get the widget data
|
// get the widget data
|
||||||
const appEvent = WidgetUtils.getRoomWidgets(persistentWidgetInRoom).find((ev) => {
|
const appEvent = WidgetUtils.getRoomWidgets(persistentWidgetInRoom).find((ev) => {
|
||||||
return ev.getStateKey() === ActiveWidgetStore.getPersistentWidgetId();
|
return ev.getStateKey() === ActiveWidgetStore.getPersistentWidgetId();
|
||||||
|
|
|
@ -105,10 +105,13 @@ export default abstract class BaseEventIndexManager {
|
||||||
/**
|
/**
|
||||||
* Initialize the event index for the given user.
|
* Initialize the event index for the given user.
|
||||||
*
|
*
|
||||||
|
* @param {string} userId The event that should be added to the index.
|
||||||
|
* @param {string} deviceId The profile of the event sender at the
|
||||||
|
*
|
||||||
* @return {Promise} A promise that will resolve when the event index is
|
* @return {Promise} A promise that will resolve when the event index is
|
||||||
* initialized.
|
* initialized.
|
||||||
*/
|
*/
|
||||||
async initEventIndex(): Promise<void> {
|
async initEventIndex(userId: string, deviceId: string): Promise<void> {
|
||||||
throw new Error("Unimplemented");
|
throw new Error("Unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ limitations under the License.
|
||||||
|
|
||||||
import PlatformPeg from "../PlatformPeg";
|
import PlatformPeg from "../PlatformPeg";
|
||||||
import EventIndex from "../indexing/EventIndex";
|
import EventIndex from "../indexing/EventIndex";
|
||||||
|
import {MatrixClientPeg} from "../MatrixClientPeg";
|
||||||
import SettingsStore from '../settings/SettingsStore';
|
import SettingsStore from '../settings/SettingsStore';
|
||||||
import {SettingLevel} from "../settings/SettingLevel";
|
import {SettingLevel} from "../settings/SettingLevel";
|
||||||
|
|
||||||
|
@ -70,9 +71,13 @@ class EventIndexPeg {
|
||||||
async initEventIndex() {
|
async initEventIndex() {
|
||||||
const index = new EventIndex();
|
const index = new EventIndex();
|
||||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||||
|
const client = MatrixClientPeg.get();
|
||||||
|
|
||||||
|
const userId = client.getUserId();
|
||||||
|
const deviceId = client.getDeviceId();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await indexManager.initEventIndex();
|
await indexManager.initEventIndex(userId, deviceId);
|
||||||
|
|
||||||
const userVersion = await indexManager.getUserVersion();
|
const userVersion = await indexManager.getUserVersion();
|
||||||
const eventIndexIsEmpty = await indexManager.isEventIndexEmpty();
|
const eventIndexIsEmpty = await indexManager.isEventIndexEmpty();
|
||||||
|
@ -83,7 +88,7 @@ class EventIndexPeg {
|
||||||
await indexManager.closeEventIndex();
|
await indexManager.closeEventIndex();
|
||||||
await this.deleteEventIndex();
|
await this.deleteEventIndex();
|
||||||
|
|
||||||
await indexManager.initEventIndex();
|
await indexManager.initEventIndex(userId, deviceId);
|
||||||
await indexManager.setUserVersion(INDEX_VERSION);
|
await indexManager.setUserVersion(INDEX_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: 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;
|
||||||
}
|
}
|
||||||
|
@ -275,8 +283,8 @@ export class StopGapWidget extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public stop() {
|
public stop(opts = {forceDestroy: false}) {
|
||||||
if (ActiveWidgetStore.getPersistentWidgetId() === this.mockWidget.id) {
|
if (!opts?.forceDestroy && ActiveWidgetStore.getPersistentWidgetId() === this.mockWidget.id) {
|
||||||
console.log("Skipping destroy - persistent widget");
|
console.log("Skipping destroy - persistent widget");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue