Moved replenishSwarm into libloki-protocol and attached to the window

pull/132/head
Beaudan 6 years ago
parent 37ba762312
commit f09f0f5721

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

@ -87,7 +87,6 @@
unlockTimestamp: null, // Timestamp used for expiring friend requests. unlockTimestamp: null, // Timestamp used for expiring friend requests.
sessionResetStatus: SessionResetEnum.none, sessionResetStatus: SessionResetEnum.none,
swarmNodes: [], swarmNodes: [],
refreshPromise: null,
}; };
}, },
@ -581,22 +580,6 @@
throw new Error('Invalid friend request state'); 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) { async setFriendRequestStatus(newStatus) {
// Ensure that the new status is a valid FriendStatusEnum value // Ensure that the new status is a valid FriendStatusEnum value
if (!(newStatus in Object.values(FriendRequestStatusEnum))) 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 // Add the message sending on another queue so that our UI doesn't get blocked
this.queueMessageSend(async () => { this.queueMessageSend(async () => {
if (this.get('swarmNodes').length === 0) { if (this.get('swarmNodes').length === 0) {
await this.refreshSwarmNodes(); await window.libloki.replenishSwarm(destination);
} }
message.send( message.send(
this.wrapSend( this.wrapSend(

Loading…
Cancel
Save