Merge branch 'develop' into widget_state_no_update_invitation_room
This commit is contained in:
@@ -252,7 +252,7 @@ export class StopGapWidget extends EventEmitter {
|
||||
return !!this.messaging;
|
||||
}
|
||||
|
||||
private onOpenModal = async (ev: CustomEvent<IModalWidgetOpenRequest>) => {
|
||||
private onOpenModal = async (ev: CustomEvent<IModalWidgetOpenRequest>): Promise<void> => {
|
||||
ev.preventDefault();
|
||||
if (ModalWidgetStore.instance.canOpenModalWidget()) {
|
||||
ModalWidgetStore.instance.openModalWidget(ev.detail.data, this.mockWidget, this.roomId);
|
||||
@@ -450,7 +450,7 @@ export class StopGapWidget extends EventEmitter {
|
||||
* widget.
|
||||
* @param opts
|
||||
*/
|
||||
public stopMessaging(opts = { forceDestroy: false }) {
|
||||
public stopMessaging(opts = { forceDestroy: false }): void {
|
||||
if (!opts?.forceDestroy && ActiveWidgetStore.instance.getWidgetPersistence(this.mockWidget.id, this.roomId)) {
|
||||
logger.log("Skipping destroy - persistent widget");
|
||||
return;
|
||||
@@ -464,24 +464,24 @@ export class StopGapWidget extends EventEmitter {
|
||||
this.client.off(ClientEvent.ToDeviceEvent, this.onToDeviceEvent);
|
||||
}
|
||||
|
||||
private onEvent = (ev: MatrixEvent) => {
|
||||
private onEvent = (ev: MatrixEvent): void => {
|
||||
this.client.decryptEventIfNeeded(ev);
|
||||
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
|
||||
this.feedEvent(ev);
|
||||
};
|
||||
|
||||
private onEventDecrypted = (ev: MatrixEvent) => {
|
||||
private onEventDecrypted = (ev: MatrixEvent): void => {
|
||||
if (ev.isDecryptionFailure()) return;
|
||||
this.feedEvent(ev);
|
||||
};
|
||||
|
||||
private onToDeviceEvent = async (ev: MatrixEvent) => {
|
||||
private onToDeviceEvent = async (ev: MatrixEvent): Promise<void> => {
|
||||
await this.client.decryptEventIfNeeded(ev);
|
||||
if (ev.isDecryptionFailure()) return;
|
||||
await this.messaging.feedToDevice(ev.getEffectiveEvent() as IRoomEvent, ev.isEncrypted());
|
||||
};
|
||||
|
||||
private feedEvent(ev: MatrixEvent) {
|
||||
private feedEvent(ev: MatrixEvent): void {
|
||||
if (!this.messaging) return;
|
||||
|
||||
// Check to see if this event would be before or after our "read up to" marker. If it's
|
||||
|
||||
@@ -63,7 +63,7 @@ function getRememberedCapabilitiesForWidget(widget: Widget): Capability[] {
|
||||
return JSON.parse(localStorage.getItem(`widget_${widget.id}_approved_caps`) || "[]");
|
||||
}
|
||||
|
||||
function setRememberedCapabilitiesForWidget(widget: Widget, caps: Capability[]) {
|
||||
function setRememberedCapabilitiesForWidget(widget: Widget, caps: Capability[]): void {
|
||||
localStorage.setItem(`widget_${widget.id}_approved_caps`, JSON.stringify(caps));
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ export class StopGapWidgetDriver extends WidgetDriver {
|
||||
|
||||
await Promise.all(
|
||||
Object.entries(contentMap).flatMap(([userId, userContentMap]) =>
|
||||
Object.entries(userContentMap).map(async ([deviceId, content]) => {
|
||||
Object.entries(userContentMap).map(async ([deviceId, content]): Promise<void> => {
|
||||
if (deviceId === "*") {
|
||||
// Send the message to all devices we have keys for
|
||||
await client.encryptAndSendToDevices(
|
||||
@@ -359,7 +359,7 @@ export class StopGapWidgetDriver extends WidgetDriver {
|
||||
return allResults;
|
||||
}
|
||||
|
||||
public async askOpenID(observer: SimpleObservable<IOpenIDUpdate>) {
|
||||
public async askOpenID(observer: SimpleObservable<IOpenIDUpdate>): Promise<void> {
|
||||
const oidcState = SdkContextClass.instance.widgetPermissionStore.getOIDCState(
|
||||
this.forWidget,
|
||||
this.forWidgetKind,
|
||||
@@ -384,7 +384,7 @@ export class StopGapWidgetDriver extends WidgetDriver {
|
||||
widgetKind: this.forWidgetKind,
|
||||
inRoomId: this.inRoomId,
|
||||
|
||||
onFinished: async (confirm) => {
|
||||
onFinished: async (confirm): Promise<void> => {
|
||||
if (!confirm) {
|
||||
return observer.update({ state: OpenIDRequestState.Blocked });
|
||||
}
|
||||
@@ -405,8 +405,8 @@ export class StopGapWidgetDriver extends WidgetDriver {
|
||||
let setTurnServer: (server: ITurnServer) => void;
|
||||
let setError: (error: Error) => void;
|
||||
|
||||
const onTurnServers = ([server]: IClientTurnServer[]) => setTurnServer(normalizeTurnServer(server));
|
||||
const onTurnServersError = (error: Error, fatal: boolean) => {
|
||||
const onTurnServers = ([server]: IClientTurnServer[]): void => setTurnServer(normalizeTurnServer(server));
|
||||
const onTurnServersError = (error: Error, fatal: boolean): void => {
|
||||
if (fatal) setError(error);
|
||||
};
|
||||
|
||||
|
||||
@@ -125,11 +125,11 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
return `update_${room.roomId}`;
|
||||
}
|
||||
|
||||
private emitFor(room: Room) {
|
||||
private emitFor(room: Room): void {
|
||||
this.emit(WidgetLayoutStore.emissionForRoom(room));
|
||||
}
|
||||
|
||||
protected async onReady(): Promise<any> {
|
||||
protected async onReady(): Promise<void> {
|
||||
this.updateAllRooms();
|
||||
|
||||
this.matrixClient.on(RoomStateEvent.Events, this.updateRoomFromState);
|
||||
@@ -138,7 +138,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
WidgetStore.instance.on(UPDATE_EVENT, this.updateFromWidgetStore);
|
||||
}
|
||||
|
||||
protected async onNotReady(): Promise<any> {
|
||||
protected async onNotReady(): Promise<void> {
|
||||
this.byRoom = {};
|
||||
|
||||
this.matrixClient?.off(RoomStateEvent.Events, this.updateRoomFromState);
|
||||
@@ -147,14 +147,14 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
WidgetStore.instance.off(UPDATE_EVENT, this.updateFromWidgetStore);
|
||||
}
|
||||
|
||||
private updateAllRooms = () => {
|
||||
private updateAllRooms = (): void => {
|
||||
this.byRoom = {};
|
||||
for (const room of this.matrixClient.getVisibleRooms()) {
|
||||
this.recalculateRoom(room);
|
||||
}
|
||||
};
|
||||
|
||||
private updateFromWidgetStore = (roomId?: string) => {
|
||||
private updateFromWidgetStore = (roomId?: string): void => {
|
||||
if (roomId) {
|
||||
const room = this.matrixClient.getRoom(roomId);
|
||||
if (room) this.recalculateRoom(room);
|
||||
@@ -163,13 +163,13 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
}
|
||||
};
|
||||
|
||||
private updateRoomFromState = (ev: MatrixEvent) => {
|
||||
private updateRoomFromState = (ev: MatrixEvent): void => {
|
||||
if (ev.getType() !== WIDGET_LAYOUT_EVENT_TYPE) return;
|
||||
const room = this.matrixClient.getRoom(ev.getRoomId());
|
||||
if (room) this.recalculateRoom(room);
|
||||
};
|
||||
|
||||
private updateFromSettings = (settingName: string, roomId: string /* and other stuff */) => {
|
||||
private updateFromSettings = (settingName: string, roomId: string /* and other stuff */): void => {
|
||||
if (roomId) {
|
||||
const room = this.matrixClient.getRoom(roomId);
|
||||
if (room) this.recalculateRoom(room);
|
||||
@@ -178,7 +178,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
}
|
||||
};
|
||||
|
||||
public recalculateRoom(room: Room) {
|
||||
public recalculateRoom(room: Room): void {
|
||||
const widgets = WidgetStore.instance.getApps(room.roomId);
|
||||
if (!widgets?.length) {
|
||||
this.byRoom[room.roomId] = {};
|
||||
@@ -380,7 +380,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
return distributions.map((d) => `${d.toFixed(1)}%`); // actual percents - these are decoded later
|
||||
}
|
||||
|
||||
public setResizerDistributions(room: Room, container: Container, distributions: string[]) {
|
||||
public setResizerDistributions(room: Room, container: Container, distributions: string[]): void {
|
||||
if (container !== Container.Top) return; // ignore - not relevant
|
||||
|
||||
const numbers = distributions.map((d) => Number(Number(d.substring(0, d.length - 1)).toFixed(1)));
|
||||
@@ -407,7 +407,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
return this.byRoom[room.roomId]?.[container]?.height; // let the default get returned if needed
|
||||
}
|
||||
|
||||
public setContainerHeight(room: Room, container: Container, height: number) {
|
||||
public setContainerHeight(room: Room, container: Container, height: number): void {
|
||||
const widgets = this.getContainerWidgets(room, container);
|
||||
const widths = this.byRoom[room.roomId]?.[container]?.distributions;
|
||||
const localLayout = {};
|
||||
@@ -422,7 +422,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
this.updateUserLayout(room, localLayout);
|
||||
}
|
||||
|
||||
public moveWithinContainer(room: Room, container: Container, widget: IApp, delta: number) {
|
||||
public moveWithinContainer(room: Room, container: Container, widget: IApp, delta: number): void {
|
||||
const widgets = arrayFastClone(this.getContainerWidgets(room, container));
|
||||
const currentIdx = widgets.findIndex((w) => w.id === widget.id);
|
||||
if (currentIdx < 0) return; // no change needed
|
||||
@@ -445,7 +445,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
this.updateUserLayout(room, localLayout);
|
||||
}
|
||||
|
||||
public moveToContainer(room: Room, widget: IApp, toContainer: Container) {
|
||||
public moveToContainer(room: Room, widget: IApp, toContainer: Container): void {
|
||||
const allWidgets = this.getAllWidgets(room);
|
||||
if (!allWidgets.some(([w]) => w.id === widget.id)) return; // invalid
|
||||
// Prepare other containers (potentially move widgets to obey the following rules)
|
||||
@@ -478,11 +478,11 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
this.updateUserLayout(room, newLayout);
|
||||
}
|
||||
|
||||
public hasMaximisedWidget(room: Room) {
|
||||
public hasMaximisedWidget(room: Room): boolean {
|
||||
return this.getContainerWidgets(room, Container.Center).length > 0;
|
||||
}
|
||||
|
||||
public hasPinnedWidgets(room: Room) {
|
||||
public hasPinnedWidgets(room: Room): boolean {
|
||||
return this.getContainerWidgets(room, Container.Top).length > 0;
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
return room.currentState.maySendStateEvent(WIDGET_LAYOUT_EVENT_TYPE, this.matrixClient.getUserId());
|
||||
}
|
||||
|
||||
public copyLayoutToRoom(room: Room) {
|
||||
public copyLayoutToRoom(room: Room): void {
|
||||
const allWidgets = this.getAllWidgets(room);
|
||||
const evContent: ILayoutStateEvent = { widgets: {} };
|
||||
for (const [widget, container] of allWidgets) {
|
||||
@@ -526,7 +526,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private updateUserLayout(room: Room, newLayout: IWidgetLayouts) {
|
||||
private updateUserLayout(room: Room, newLayout: IWidgetLayouts): void {
|
||||
// Polyfill any missing widgets
|
||||
const allWidgets = this.getAllWidgets(room);
|
||||
for (const [widget, container] of allWidgets) {
|
||||
|
||||
@@ -58,7 +58,7 @@ export class WidgetMessagingStore extends AsyncStoreWithClient<{}> {
|
||||
this.widgetMap.clear();
|
||||
}
|
||||
|
||||
public storeMessaging(widget: Widget, roomId: string, widgetApi: ClientWidgetApi) {
|
||||
public storeMessaging(widget: Widget, roomId: string, widgetApi: ClientWidgetApi): void {
|
||||
this.stopMessaging(widget, roomId);
|
||||
const uid = WidgetUtils.calcWidgetUid(widget.id, roomId);
|
||||
this.widgetMap.set(uid, widgetApi);
|
||||
@@ -66,7 +66,7 @@ export class WidgetMessagingStore extends AsyncStoreWithClient<{}> {
|
||||
this.emit(WidgetMessagingStoreEvent.StoreMessaging, uid, widgetApi);
|
||||
}
|
||||
|
||||
public stopMessaging(widget: Widget, roomId: string) {
|
||||
public stopMessaging(widget: Widget, roomId: string): void {
|
||||
this.stopMessagingByUid(WidgetUtils.calcWidgetUid(widget.id, roomId));
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export class WidgetMessagingStore extends AsyncStoreWithClient<{}> {
|
||||
* Stops the widget messaging instance for a given widget UID.
|
||||
* @param {string} widgetUid The widget UID.
|
||||
*/
|
||||
public stopMessagingByUid(widgetUid: string) {
|
||||
public stopMessagingByUid(widgetUid: string): void {
|
||||
this.widgetMap.remove(widgetUid)?.stop();
|
||||
this.emit(WidgetMessagingStoreEvent.StopMessaging, widgetUid);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export class WidgetPermissionStore {
|
||||
return OIDCState.Unknown;
|
||||
}
|
||||
|
||||
public setOIDCState(widget: Widget, kind: WidgetKind, roomId: string, newState: OIDCState) {
|
||||
public setOIDCState(widget: Widget, kind: WidgetKind, roomId: string, newState: OIDCState): void {
|
||||
const settingsKey = this.packSettingKey(widget, kind, roomId);
|
||||
|
||||
let currentValues = SettingsStore.getValue("widgetOpenIDPermissions");
|
||||
|
||||
Reference in New Issue
Block a user