From 75660c726932de20f5519248b94a6b207e4ea614 Mon Sep 17 00:00:00 2001 From: Mikunj Varsani Date: Thu, 6 Feb 2020 14:36:58 +1100 Subject: [PATCH 1/3] fixed file server holding up message sender init. fix joining closed groups. --- js/background.js | 19 +++++++++++++++++-- .../session/LeftPaneChannelSection.tsx | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/js/background.js b/js/background.js index 8d5ebd1f1..2bbc96db6 100644 --- a/js/background.js +++ b/js/background.js @@ -238,6 +238,18 @@ specialConvInited = true; }; + const initLokiMessageAPIs = () => { + const ourKey = textsecure.storage.user.getNumber(); + if (!window.lokiMessageAPI) { + window.lokiMessageAPI = new window.LokiMessageAPI(ourKey); + } + + if (!window.lokiPublicChatAPI) { + // singleton to relay events to libtextsecure/message_receiver + window.lokiPublicChatAPI = new window.LokiPublicChatAPI(ourKey); + } + }; + const initAPIs = async () => { if (window.initialisedAPI) { return; @@ -1488,8 +1500,8 @@ return; } - await initAPIs(); - await initSpecialConversations(); + initLokiMessageAPIs(); + messageReceiver = new textsecure.MessageReceiver( USERNAME, PASSWORD, @@ -1525,6 +1537,9 @@ PASSWORD ); + await initAPIs(); + await initSpecialConversations(); + // On startup after upgrading to a new version, request a contact sync // (but only if we're not the primary device) if ( diff --git a/ts/components/session/LeftPaneChannelSection.tsx b/ts/components/session/LeftPaneChannelSection.tsx index f7a9cdd08..c5131f448 100644 --- a/ts/components/session/LeftPaneChannelSection.tsx +++ b/ts/components/session/LeftPaneChannelSection.tsx @@ -406,7 +406,8 @@ export class LeftPaneChannelSection extends React.Component { return; } - await window.doCreateGroup(groupName, groupMembers); + const groupMemberIds = groupMembers.map(m => m.id); + await window.doCreateGroup(groupName, groupMemberIds); this.handleToggleOverlay(undefined); window.pushToast({ From 8b1e24fc44e952c56791ace49460ce824910f829 Mon Sep 17 00:00:00 2001 From: Mikunj Varsani Date: Thu, 6 Feb 2020 14:38:58 +1100 Subject: [PATCH 2/3] Clean --- js/background.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/background.js b/js/background.js index 2bbc96db6..375338e89 100644 --- a/js/background.js +++ b/js/background.js @@ -241,6 +241,7 @@ const initLokiMessageAPIs = () => { const ourKey = textsecure.storage.user.getNumber(); if (!window.lokiMessageAPI) { + window.feeds = []; window.lokiMessageAPI = new window.LokiMessageAPI(ourKey); } @@ -255,10 +256,7 @@ return; } const ourKey = textsecure.storage.user.getNumber(); - window.feeds = []; - window.lokiMessageAPI = new window.LokiMessageAPI(ourKey); - // singleton to relay events to libtextsecure/message_receiver - window.lokiPublicChatAPI = new window.LokiPublicChatAPI(ourKey); + // singleton to interface the File server // If already exists we registered as a secondary device if (!window.lokiFileServerAPI) { From c37650c45d66f266c92c7bbd9be61908c15f38fa Mon Sep 17 00:00:00 2001 From: Mikunj Varsani Date: Thu, 6 Feb 2020 14:51:00 +1100 Subject: [PATCH 3/3] Don't wait for file server to return tokens when establishing home connection. --- js/background.js | 31 +++++++++--------------------- js/modules/loki_file_server_api.js | 4 ++-- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/js/background.js b/js/background.js index 375338e89..85f040d99 100644 --- a/js/background.js +++ b/js/background.js @@ -238,30 +238,20 @@ specialConvInited = true; }; - const initLokiMessageAPIs = () => { - const ourKey = textsecure.storage.user.getNumber(); - if (!window.lokiMessageAPI) { - window.feeds = []; - window.lokiMessageAPI = new window.LokiMessageAPI(ourKey); - } - - if (!window.lokiPublicChatAPI) { - // singleton to relay events to libtextsecure/message_receiver - window.lokiPublicChatAPI = new window.LokiPublicChatAPI(ourKey); - } - }; - - const initAPIs = async () => { + const initAPIs = () => { if (window.initialisedAPI) { return; } const ourKey = textsecure.storage.user.getNumber(); - + window.feeds = []; + window.lokiMessageAPI = new window.LokiMessageAPI(ourKey); + // singleton to relay events to libtextsecure/message_receiver + window.lokiPublicChatAPI = new window.LokiPublicChatAPI(ourKey); // singleton to interface the File server // If already exists we registered as a secondary device if (!window.lokiFileServerAPI) { window.lokiFileServerAPIFactory = new window.LokiFileServerAPI(ourKey); - window.lokiFileServerAPI = await window.lokiFileServerAPIFactory.establishHomeConnection( + window.lokiFileServerAPI = window.lokiFileServerAPIFactory.establishHomeConnection( window.getDefaultFileServer() ); } @@ -1478,7 +1468,7 @@ const ourKey = textsecure.storage.user.getNumber(); window.lokiMessageAPI = new window.LokiMessageAPI(ourKey); window.lokiFileServerAPIFactory = new window.LokiFileServerAPI(ourKey); - window.lokiFileServerAPI = await window.lokiFileServerAPIFactory.establishHomeConnection( + window.lokiFileServerAPI = window.lokiFileServerAPIFactory.establishHomeConnection( window.getDefaultFileServer() ); window.lokiPublicChatAPI = null; @@ -1498,8 +1488,8 @@ return; } - initLokiMessageAPIs(); - + initAPIs(); + await initSpecialConversations(); messageReceiver = new textsecure.MessageReceiver( USERNAME, PASSWORD, @@ -1535,9 +1525,6 @@ PASSWORD ); - await initAPIs(); - await initSpecialConversations(); - // On startup after upgrading to a new version, request a contact sync // (but only if we're not the primary device) if ( diff --git a/js/modules/loki_file_server_api.js b/js/modules/loki_file_server_api.js index 601ab2e9a..c38609467 100644 --- a/js/modules/loki_file_server_api.js +++ b/js/modules/loki_file_server_api.js @@ -291,14 +291,14 @@ class LokiFileServerFactoryAPI { this.servers = []; } - async establishHomeConnection(serverUrl) { + establishHomeConnection(serverUrl) { let thisServer = this.servers.find( server => server._server.baseServerUrl === serverUrl ); if (!thisServer) { thisServer = new LokiHomeServerInstance(this.ourKey); log.info(`Registering HomeServer ${serverUrl}`); - await thisServer.establishConnection(serverUrl); + thisServer.establishConnection(serverUrl); this.servers.push(thisServer); } return thisServer;