Files
mattermost-mobile/app/actions/websocket/system.ts
Shaz Amjad 826c6683f8 Gekidou - Sidebar websocket handling (#5954)
* Adds actions, queries, db models and rest client

* Adds Websocket handling for categories

* fix merge

* small refactor for categories websocket events

* fix bad merge

* Category delete handled

* Handles deletion (prune on store)

* Resolves feedback, adds team handling for prune

* Minor fixes; param order and return, imports, type naming

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2022-02-17 08:07:31 +11:00

42 lines
1.3 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {SYSTEM_IDENTIFIERS} from '@constants/database';
import DatabaseManager from '@database/manager';
export async function handleLicenseChangedEvent(serverUrl: string, msg: WebSocketMessage): Promise<void> {
const operator = DatabaseManager.serverDatabases[serverUrl]?.operator;
if (!operator) {
return;
}
try {
const license = msg.data.license;
const systems: IdValue[] = [{
id: SYSTEM_IDENTIFIERS.LICENSE,
value: JSON.stringify(license),
}];
await operator.handleSystem({systems, prepareRecordsOnly: false});
} catch {
// do nothing
}
}
export async function handleConfigChangedEvent(serverUrl: string, msg: WebSocketMessage): Promise<void> {
const operator = DatabaseManager.serverDatabases[serverUrl]?.operator;
if (!operator) {
return;
}
try {
const config = msg.data.config;
const systems: IdValue[] = [{
id: SYSTEM_IDENTIFIERS.CONFIG,
value: JSON.stringify(config),
}];
await operator.handleSystem({systems, prepareRecordsOnly: false});
} catch {
// do nothing
}
}