Moved replenishSwarm into libloki-protocol and attached to the window

This commit is contained in:
Beaudan 2019-01-09 14:43:58 +11:00
parent 37ba762312
commit f09f0f5721
2 changed files with 2 additions and 19 deletions

View file

@ -174,7 +174,7 @@
return conversation;
}
conversation.refreshSwarmNodes();
window.libloki.replenishSwarm(id);
try {
await window.Signal.Data.saveConversation(conversation.attributes, {
Conversation: Whisper.Conversation,

View file

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