Don't wait for file server to return tokens when establishing home connection.

pull/797/head
Mikunj Varsani 5 years ago
parent 8b1e24fc44
commit c37650c45d

@ -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 (

@ -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;

Loading…
Cancel
Save