diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 9f51f9157..ea93a3437 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -87,7 +87,6 @@ ); } - console.log('[vince] Creating conversation with id:', id); diff --git a/js/models/conversations.js b/js/models/conversations.js index de6a47567..362f1f051 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1004,7 +1004,6 @@ }); }, async respondToAllFriendRequests(options) { - const { response, status, direction = null } = options; // Ignore if no response supplied if (!response) { @@ -1020,13 +1019,8 @@ return; } - console.log('[vince] allDevices:', allDevices); const allConversationsWithUser = allDevices.map(d => ConversationController.get(d)); - console.log('[vince][fr] allConversationsWithUser:', allConversationsWithUser); - console.log('[vince][fr] direction:', direction); - console.log(`[vince][fr] Status: `, status); - const pendingRequests = await allConversationsWithUser.reduce(async (requestsP, conversation) => { const requests = await requestsP; const request = (await conversation.getFriendRequests(direction, status))[0]; @@ -1034,14 +1028,10 @@ return request ? requests.concat({ conversation, request }) : requests; }, []); - console.log('[vince][fr] pendingRequests:', pendingRequests); - await Promise.all( pendingRequests.map(async friendRequest => { const { conversation, request } = friendRequest; - console.log('[vince][fr] friendRequest:', friendRequest); - if (request.hasErrors()) { return; } @@ -1053,7 +1043,6 @@ conversation.trigger('updateMessage', request); }) ); - }, async respondToAllPendingFriendRequests(options) { return this.respondToAllFriendRequests({ diff --git a/js/models/messages.js b/js/models/messages.js index 991eef62f..bf7a36a54 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -415,38 +415,34 @@ }, async acceptFriendRequest() { - // THIS FUNCTION RUNS WHEN "ACCEPT" BUTTON IN CHAT IS CLICKED - if (this.get('friendStatus') !== 'pending') { return; } - const conversation = await this.getSourceDeviceConversation(); - - console.log('[vince][fr] conversation:', conversation); - console.log('[vince][fr] sourceDeviceConversation():', await this.getSourceDeviceConversation()); - - - // If we somehow received an old friend request (e.g. after having restored - // from seed, we won't be able to accept it, we should initiate our own - // friend request to reset the session: - if (conversation.get('sessionRestoreSeen')) { - conversation.sendMessage('', null, null, null, null, { - sessionRestoration: true, - }); - return; - } - - // TESTING turning this off - // this.set({ friendStatus: 'accepted' }); + const allDevices = await libloki.storage.getAllDevicePubKeysForPrimaryPubKey( + this.attributes.conversationId + ); - console.log('[vince][core] this.attributes:', this.attributes); - console.log('[vince][core] This is the conversation youre accepting!! :', conversation); + const allConversationsWithUser = allDevices.map(d => ConversationController.get(d)); + allConversationsWithUser.forEach(conversation => { + // If we somehow received an old friend request (e.g. after having restored + // from seed, we won't be able to accept it, we should initiate our own + // friend request to reset the session: + if (conversation.get('sessionRestoreSeen')) { + conversation.sendMessage('', null, null, null, null, { + sessionRestoration: true, + }); + return; + } + conversation.onAcceptFriendRequest(); + }); + await window.Signal.Data.saveMessage(this.attributes, { Message: Whisper.Message, }); - conversation.onAcceptFriendRequest(); + + this.set({ friendStatus: 'accepted' }); }, async declineFriendRequest() { if (this.get('friendStatus') !== 'pending') {