Chore: Migrate methods/enterpriseModules to TS (#3706)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
e58bdb8fe7
commit
c5cc192dc9
|
@ -1,5 +1,7 @@
|
|||
import Model from '@nozbe/watermelondb/Model';
|
||||
|
||||
import { IEnterpriseModules } from '../reducers/enterpriseModules';
|
||||
|
||||
export interface IServer {
|
||||
name: string;
|
||||
iconURL: string;
|
||||
|
@ -13,7 +15,7 @@ export interface IServer {
|
|||
autoLockTime?: number;
|
||||
biometry?: boolean;
|
||||
uniqueID: string;
|
||||
enterpriseModules: string;
|
||||
enterpriseModules: IEnterpriseModules;
|
||||
E2E_Enable: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import sdk from '../rocketchat/services/sdk';
|
||||
import { compareServerVersion } from '../utils';
|
||||
import { store as reduxStore } from '../auxStore';
|
||||
import database from '../database';
|
||||
import log from '../../utils/log';
|
||||
import { clearEnterpriseModules, setEnterpriseModules as setEnterpriseModulesAction } from '../../actions/enterpriseModules';
|
||||
|
||||
export const LICENSE_OMNICHANNEL_MOBILE_ENTERPRISE = 'omnichannel-mobile-enterprise';
|
||||
export const LICENSE_LIVECHAT_ENTERPRISE = 'livechat-enterprise';
|
||||
const LICENSE_OMNICHANNEL_MOBILE_ENTERPRISE = 'omnichannel-mobile-enterprise';
|
||||
const LICENSE_LIVECHAT_ENTERPRISE = 'livechat-enterprise';
|
||||
|
||||
export async function setEnterpriseModules() {
|
||||
try {
|
||||
|
@ -29,17 +30,17 @@ export async function setEnterpriseModules() {
|
|||
}
|
||||
|
||||
export function getEnterpriseModules() {
|
||||
return new Promise(async resolve => {
|
||||
return new Promise<void>(async resolve => {
|
||||
try {
|
||||
const { version: serverVersion, server: serverId } = reduxStore.getState().server;
|
||||
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '3.1.0')) {
|
||||
// RC 3.1.0
|
||||
const enterpriseModules = await this.methodCallWrapper('license:getModules');
|
||||
const enterpriseModules = await sdk.methodCallWrapper('license:getModules');
|
||||
if (enterpriseModules) {
|
||||
const serversDB = database.servers;
|
||||
const serversCollection = serversDB.get('servers');
|
||||
const server = await serversCollection.find(serverId);
|
||||
await serversDB.action(async () => {
|
||||
await serversDB.write(async () => {
|
||||
await server.update(s => {
|
||||
s.enterpriseModules = enterpriseModules.join(',');
|
||||
});
|
||||
|
@ -56,7 +57,7 @@ export function getEnterpriseModules() {
|
|||
});
|
||||
}
|
||||
|
||||
export function hasLicense(module) {
|
||||
export function hasLicense(module: string) {
|
||||
const { enterpriseModules } = reduxStore.getState();
|
||||
return enterpriseModules.includes(module);
|
||||
}
|
|
@ -18,7 +18,7 @@ const methods = {
|
|||
};
|
||||
|
||||
export const compareServerVersion = (
|
||||
currentServerVersion: string,
|
||||
currentServerVersion: string | null,
|
||||
method: keyof typeof methods,
|
||||
versionToCompare: string
|
||||
): boolean =>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { TActionEnterpriseModules } from '../actions/enterpriseModules';
|
||||
import { ENTERPRISE_MODULES } from '../actions/actionsTypes';
|
||||
|
||||
export type IEnterpriseModules = 'omnichannel-mobile-enterprise' | 'livechat-enterprise';
|
||||
export type IEnterpriseModules = string;
|
||||
|
||||
export const initialState: IEnterpriseModules[] = [];
|
||||
|
||||
|
|
Loading…
Reference in New Issue