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

Commit 5ee0262

Browse files
committed
Post-merge tidy up
Signed-off-by: Michael Telatynski <[email protected]>
1 parent bec1d71 commit 5ee0262

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

src/stores/WidgetStore.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
import { Room } from "matrix-js-sdk/src/models/room";
1818
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
19+
import { IWidget } from "matrix-widget-api";
1920

2021
import { ActionPayload } from "../dispatcher/payloads";
2122
import { AsyncStoreWithClient } from "./AsyncStoreWithClient";
@@ -30,18 +31,9 @@ import {UPDATE_EVENT} from "./AsyncStore";
3031

3132
interface IState {}
3233

33-
export interface IApp {
34-
id: string;
35-
url: string;
36-
type: string;
37-
name: string;
34+
export interface IApp extends IWidget {
3835
roomId: string;
3936
eventId: string;
40-
creatorUserId: string;
41-
waitForIframeLoad?: boolean;
42-
data?: {
43-
title?: string;
44-
};
4537
// eslint-disable-next-line camelcase
4638
avatar_url: string; // MSC2765 https://github.com/matrix-org/matrix-doc/pull/2765
4739
}

src/utils/WidgetUtils.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ import {Room} from "matrix-js-sdk/src/models/room";
3030
import {WidgetType} from "../widgets/WidgetType";
3131
import {objectClone} from "./objects";
3232
import {_t} from "../languageHandler";
33-
import {MatrixCapabilities} from "matrix-widget-api";
33+
import {Capability, IWidgetData, MatrixCapabilities} from "matrix-widget-api";
3434
import {IApp} from "../stores/WidgetStore"; // TODO @@
3535

3636
// How long we wait for the state event echo to come back from the server
3737
// before waitFor[Room/User]Widget rejects its promise
3838
const WIDGET_WAIT_TIME = 20000;
3939

40-
export interface IWidget { // TODO @@
40+
export interface IWidgetEvent {
4141
id: string;
4242
type: string;
4343
sender: string;
@@ -230,7 +230,7 @@ export default class WidgetUtils {
230230
widgetType: WidgetType,
231231
widgetUrl: string,
232232
widgetName: string,
233-
widgetData: object,
233+
widgetData: IWidgetData,
234234
) {
235235
const content = {
236236
type: widgetType.preferred,
@@ -332,7 +332,7 @@ export default class WidgetUtils {
332332
* Get user specific widgets (not linked to a specific room)
333333
* @return {object} Event content object containing current / active user widgets
334334
*/
335-
static getUserWidgets(): Record<string, IWidget> {
335+
static getUserWidgets(): Record<string, IWidgetEvent> {
336336
const client = MatrixClientPeg.get();
337337
if (!client) {
338338
throw new Error('User not logged in');
@@ -348,15 +348,15 @@ export default class WidgetUtils {
348348
* Get user specific widgets (not linked to a specific room) as an array
349349
* @return {[object]} Array containing current / active user widgets
350350
*/
351-
static getUserWidgetsArray(): IWidget[] {
351+
static getUserWidgetsArray(): IWidgetEvent[] {
352352
return Object.values(WidgetUtils.getUserWidgets());
353353
}
354354

355355
/**
356356
* Get active stickerpicker widgets (stickerpickers are user widgets by nature)
357357
* @return {[object]} Array containing current / active stickerpicker widgets
358358
*/
359-
static getStickerpickerWidgets(): IWidget[] {
359+
static getStickerpickerWidgets(): IWidgetEvent[] {
360360
const widgets = WidgetUtils.getUserWidgetsArray();
361361
return widgets.filter((widget) => widget.content && widget.content.type === "m.stickerpicker");
362362
}
@@ -365,12 +365,12 @@ export default class WidgetUtils {
365365
* Get all integration manager widgets for this user.
366366
* @returns {Object[]} An array of integration manager user widgets.
367367
*/
368-
static getIntegrationManagerWidgets(): IWidget[] {
368+
static getIntegrationManagerWidgets(): IWidgetEvent[] {
369369
const widgets = WidgetUtils.getUserWidgetsArray();
370370
return widgets.filter(w => w.content && w.content.type === "m.integration_manager");
371371
}
372372

373-
static getRoomWidgetsOfType(room: Room, type: WidgetType): IWidget[] {
373+
static getRoomWidgetsOfType(room: Room, type: WidgetType): IWidgetEvent[] {
374374
const widgets = WidgetUtils.getRoomWidgets(room);
375375
return (widgets || []).filter(w => {
376376
const content = w.getContent();
@@ -385,7 +385,7 @@ export default class WidgetUtils {
385385
}
386386
const widgets = client.getAccountData('m.widgets');
387387
if (!widgets) return;
388-
const userWidgets: IWidget[] = widgets.getContent() || {};
388+
const userWidgets: IWidgetEvent[] = widgets.getContent() || {};
389389
Object.entries(userWidgets).forEach(([key, widget]) => {
390390
if (widget.content && widget.content.type === "m.integration_manager") {
391391
delete userWidgets[key];
@@ -415,7 +415,7 @@ export default class WidgetUtils {
415415
}
416416
const widgets = client.getAccountData('m.widgets');
417417
if (!widgets) return;
418-
const userWidgets: Record<string, IWidget> = widgets.getContent() || {};
418+
const userWidgets: Record<string, IWidgetEvent> = widgets.getContent() || {};
419419
Object.entries(userWidgets).forEach(([key, widget]) => {
420420
if (widget.content && widget.content.type === 'm.stickerpicker') {
421421
delete userWidgets[key];

0 commit comments

Comments
 (0)