update: ILoginResultFromServer

remove: `shareSDK` from IRocketChat
update: `getWebsocketInfo`
add: connect method to SDK
This commit is contained in:
Gerzon Z 2022-03-02 12:42:40 -04:00
parent ab8ff58fba
commit 3aa227e699
4 changed files with 12 additions and 22 deletions

View File

@ -23,28 +23,16 @@ export interface ILoggedUser {
enableMessageParserEarlyAdoption?: boolean; enableMessageParserEarlyAdoption?: boolean;
} }
export interface ILoggedUserResultFromServer
extends Omit<ILoggedUser, 'enableMessageParserEarlyAdoption' | 'showMessageInMainThread'> {
settings: IUserSettings;
}
export interface ILoginResultFromServer { export interface ILoginResultFromServer {
status: string; status: string;
authToken: string; authToken: string;
userId: string; userId: string;
me: { me: ILoggedUserResultFromServer;
id: string;
token: string;
username: string;
name: string;
language?: string;
status: UserStatus;
statusText?: string;
customFields?: {
[key: string]: any;
};
statusLivechat?: string;
emails?: IUserEmail[];
roles?: string[];
avatarETag?: string;
isFromWebView?: boolean;
settings: IUserSettings;
};
} }
export type TLoggedUserModel = ILoggedUser & Model; export type TLoggedUserModel = ILoggedUser & Model;

View File

@ -4,7 +4,6 @@ type TRocketChat = typeof rocketchat;
export interface IRocketChat extends TRocketChat { export interface IRocketChat extends TRocketChat {
sdk: any; sdk: any;
shareSDK: any;
activeUsersSubTimeout: any; activeUsersSubTimeout: any;
roomsSub: any; roomsSub: any;
} }

View File

@ -1,7 +1,6 @@
import RNFetchBlob from 'rn-fetch-blob'; import RNFetchBlob from 'rn-fetch-blob';
import { Rocketchat as RocketchatClient, settings as RocketChatSettings } from '@rocket.chat/sdk'; import { settings as RocketChatSettings } from '@rocket.chat/sdk';
import { useSsl } from '../../../utils/url';
import { selectServerFailure } from '../../../actions/server'; import { selectServerFailure } from '../../../actions/server';
import { twoFactor } from '../../../utils/twoFactor'; import { twoFactor } from '../../../utils/twoFactor';
import { compareServerVersion } from '../../utils'; import { compareServerVersion } from '../../utils';
@ -183,7 +182,7 @@ async function getServerInfo(server: string) {
} }
async function getWebsocketInfo({ server }: { server: string }) { async function getWebsocketInfo({ server }: { server: string }) {
const sdk = new RocketchatClient({ host: server, protocol: 'ddp', useSsl: useSsl(server) }); sdk.initialize(server);
try { try {
await sdk.connect(); await sdk.connect();

View File

@ -174,6 +174,10 @@ class Sdk {
abort() { abort() {
return this.sdk.abort(); return this.sdk.abort();
} }
connect() {
return this.sdk.connect();
}
} }
const sdk = new Sdk(); const sdk = new Sdk();