diff --git a/ts/session/types/OpenGroup.ts b/ts/session/types/OpenGroup.ts index 11a8edf15..a5990efad 100644 --- a/ts/session/types/OpenGroup.ts +++ b/ts/session/types/OpenGroup.ts @@ -89,17 +89,27 @@ export class OpenGroup { // Make this not hard coded const channel = 1; - const conversation = window.attemptConnection(server, channel); - const groupId = OpenGroup.getGroupId(server, channel); + let conversation; + try { + conversation = await window.attemptConnection(server, channel); + } catch (e) { + console.warn(e); + return; + } return new OpenGroup({ server, - groupId, - conversation.cid, - }) - - return {serverInfo, connectionPromise}; + channel, + conversationId: conversation?.cid, + }); + } + + public static async isConnected(server: string): Promise { + if (!OpenGroup.validate(server)) { + return false; + } + return Boolean(window.lokiPublicChatAPI.findOrCreateServer(server)); } private static getServer(groupId: string, hasSSL: boolean): string | undefined {