From f09f0f5721dc7825205df268213ce910fabd9398 Mon Sep 17 00:00:00 2001 From: Beaudan Date: Wed, 9 Jan 2019 14:43:58 +1100 Subject: [PATCH] Moved replenishSwarm into libloki-protocol and attached to the window --- js/conversation_controller.js | 2 +- js/models/conversations.js | 19 +------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 2a72fa2fe..ca0d5658b 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -174,7 +174,7 @@ return conversation; } - conversation.refreshSwarmNodes(); + window.libloki.replenishSwarm(id); try { await window.Signal.Data.saveConversation(conversation.attributes, { Conversation: Whisper.Conversation, diff --git a/js/models/conversations.js b/js/models/conversations.js index 0e052c310..c18984757 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -87,7 +87,6 @@ unlockTimestamp: null, // Timestamp used for expiring friend requests. sessionResetStatus: SessionResetEnum.none, swarmNodes: [], - refreshPromise: null, }; }, @@ -581,22 +580,6 @@ throw new Error('Invalid friend request state'); } }, - async refreshSwarmNodes() { - // Refresh promise to ensure that we are only doing a single query at a time - let refreshPromise = this.get('refreshPromise'); - if (refreshPromise === null) { - refreshPromise = (async () => { - const newSwarmNodes = await window.LokiAPI.getSwarmNodes(this.id); - this.set({ swarmNodes: _.union(this.get('swarmNodes'), newSwarmNodes) }); - await window.Signal.Data.updateConversation(this.id, this.attributes, { - Conversation: Whisper.Conversation, - }); - })(); - this.set({ refreshPromise }); - } - await refreshPromise; - this.set({ refreshPromise: null }); - }, async setFriendRequestStatus(newStatus) { // Ensure that the new status is a valid FriendStatusEnum value if (!(newStatus in Object.values(FriendRequestStatusEnum))) @@ -1218,7 +1201,7 @@ // Add the message sending on another queue so that our UI doesn't get blocked this.queueMessageSend(async () => { if (this.get('swarmNodes').length === 0) { - await this.refreshSwarmNodes(); + await window.libloki.replenishSwarm(destination); } message.send( this.wrapSend(