From 6f0062d0230cebe4e08bc4e5bafaa8fe22b0228f Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 19 Aug 2019 14:37:55 +0200 Subject: [PATCH] Add comments and timeout errors --- www/common/outer/async-store.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 417fd0fa8..e4a85a89c 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1241,6 +1241,10 @@ define([ channel.sendMessage(msg, clientId, cb); }; + // requestPadAccess is used to check if we have a way to contact the owner + // of the pad AND to send the request if we want + // data.send === false ==> check if we can contact them + // data.send === true ==> send the request Store.requestPadAccess = function (clientId, data, cb) { var owner = data.owner; var channel = channels[data.channel]; @@ -1255,13 +1259,15 @@ define([ } if (i >= 300) { // One minute timeout clearInterval(it); + return void cb({error: 'ETIMEOUT'}); } i++; }, 200); return; } - // If the owner was not is the pad metadata, check if it is a friend + // If the owner was not is the pad metadata, check if it is a friend. + // We'll contact the first owner for whom we know the mailbox var fData = channel.data || {}; if (!owner && fData.owners) { var friends = store.proxy.friends || {}; @@ -1348,6 +1354,7 @@ define([ } if (i >= 300) { // One minute timeout clearInterval(it); + return void cb({error: 'ETIMEOUT'}); } i++; }, 200);