Chore: Fix websocket connection to sdk (#4182)
This commit is contained in:
parent
4a84e47cfa
commit
9d514690f0
|
@ -1,5 +1,5 @@
|
|||
import RNFetchBlob from 'rn-fetch-blob';
|
||||
import { settings as RocketChatSettings } from '@rocket.chat/sdk';
|
||||
import { settings as RocketChatSettings, Rocketchat as RocketchatClient } from '@rocket.chat/sdk';
|
||||
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
|
||||
import { InteractionManager } from 'react-native';
|
||||
import { Q } from '@nozbe/watermelondb';
|
||||
|
@ -23,6 +23,7 @@ import { updateSettings } from '../../actions/settings';
|
|||
import { defaultSettings, MIN_ROCKETCHAT_VERSION } from '../constants';
|
||||
import { compareServerVersion } from '../methods/helpers/compareServerVersion';
|
||||
import { onRolesChanged } from '../methods/getRoles';
|
||||
import { isSsl } from '../../utils/url';
|
||||
import { getSettings, IActiveUsers, unsubscribeRooms, _activeUsers, _setUser, _setUserTimer } from '../methods';
|
||||
|
||||
interface IServices {
|
||||
|
@ -425,10 +426,10 @@ async function getServerInfo(server: string) {
|
|||
}
|
||||
|
||||
async function getWebsocketInfo({ server }: { server: string }) {
|
||||
sdk.initialize(server);
|
||||
const websocketSdk = new RocketchatClient({ host: server, protocol: 'ddp', useSsl: isSsl(server) });
|
||||
|
||||
try {
|
||||
await sdk.current.connect();
|
||||
await websocketSdk.connect();
|
||||
} catch (err: any) {
|
||||
if (err.message && err.message.includes('400')) {
|
||||
return {
|
||||
|
@ -438,7 +439,7 @@ async function getWebsocketInfo({ server }: { server: string }) {
|
|||
}
|
||||
}
|
||||
|
||||
sdk.disconnect();
|
||||
websocketSdk.disconnect();
|
||||
|
||||
return {
|
||||
success: true
|
||||
|
|
Loading…
Reference in New Issue