Eliminate the use of MatrixClientPeg in utils (#10910)

This commit is contained in:
Michael Telatynski 2023-05-23 16:24:12 +01:00 committed by GitHub
parent a0c2676c38
commit 30429df948
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
108 changed files with 409 additions and 325 deletions

View file

@ -411,6 +411,7 @@ function kickUser(event: MessageEvent<any>, roomId: string, userId: string): voi
}
function setWidget(event: MessageEvent<any>, roomId: string | null): void {
const client = MatrixClientPeg.get();
const widgetId = event.data.widget_id;
let widgetType = event.data.type;
const widgetUrl = event.data.url;
@ -458,7 +459,7 @@ function setWidget(event: MessageEvent<any>, roomId: string | null): void {
widgetType = WidgetType.fromString(widgetType);
if (userWidget) {
WidgetUtils.setUserWidget(widgetId, widgetType, widgetUrl, widgetName, widgetData)
WidgetUtils.setUserWidget(client, widgetId, widgetType, widgetUrl, widgetName, widgetData)
.then(() => {
sendResponse(event, {
success: true,
@ -476,6 +477,7 @@ function setWidget(event: MessageEvent<any>, roomId: string | null): void {
return;
}
WidgetUtils.setRoomWidget(
client,
roomId,
widgetId,
widgetType,
@ -516,7 +518,7 @@ function getWidgets(event: MessageEvent<any>, roomId: string | null): void {
}
// Add user widgets (not linked to a specific room)
const userWidgets = WidgetUtils.getUserWidgetsArray();
const userWidgets = WidgetUtils.getUserWidgetsArray(client);
widgetStateEvents = widgetStateEvents.concat(userWidgets);
sendResponse(event, widgetStateEvents);