Files
mattermost-mobile/app/actions/websocket/integrations.ts
Daniel Espino García e047106bac Add AppsForm and Interactive Dialogs (#6142)
* Add AppsForm and Interactive Dialogs

* Add the missing plumbing for Interactive Dialogs and minor fixes

* Remove widgets subfolder

* Fix paths

* Address feedback

* Address feedback

* i18n extract

* Only set the dialog if we are in the same server
2022-04-28 18:26:21 +02:00

27 lines
880 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import DatabaseManager from '@database/manager';
import IntegrationsManager from '@managers/integrations_manager';
import {getActiveServerUrl} from '@queries/app/servers';
export async function handleOpenDialogEvent(serverUrl: string, msg: WebSocketMessage) {
const data: string = msg.data?.dialog;
if (!data) {
return;
}
const appDatabase = DatabaseManager.appDatabase?.database;
if (!appDatabase) {
return;
}
try {
const dialog: InteractiveDialogConfig = JSON.parse(data);
const currentServer = await getActiveServerUrl(appDatabase);
if (currentServer === serverUrl) {
IntegrationsManager.getManager(serverUrl).setDialog(dialog);
}
} catch {
// Do nothing
}
}