From c3d3ec125d8c54453ac4e4100e10afb4036526bc Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 6 Aug 2015 12:30:51 -0700 Subject: [PATCH] Wait for contact sync before opening inbox Use a canned bootstrap progress animation in lieu of better design. Fix #271 // FREEBIE --- js/libtextsecure.js | 1 + js/options.js | 13 +++++++++++-- libtextsecure/message_receiver.js | 1 + options.html | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 976d2fd73..79cd43a4e 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -39714,6 +39714,7 @@ function generateKeys(count, progressCallback) { eventTarget.dispatchEvent(ev); contactDetails = contactBuffer.next(); } + eventTarget.dispatchEvent(new Event('textsecure:contactsync')); }); }, handleGroups: function(groups) { diff --git a/js/options.js b/js/options.js index cee7e0f72..c65153e30 100644 --- a/js/options.js +++ b/js/options.js @@ -79,8 +79,17 @@ var accountManager = new bg.textsecure.AccountManager(); accountManager.registerSecondDevice(setProvisioningUrl, confirmNumber, incrementCounter).then(function() { - bg.openInbox(); - window.close(); + var launch = function() { + bg.openInbox(); + bg.removeEventListener('textsecure:contactsync', launch); + clearTimeout(timeout); + window.close(); + }; + var timeout = setTimeout(launch, 60000); + bg.addEventListener('textsecure:contactsync', launch); + $('.progress-dialog .status').text('Syncing groups and contacts'); + $('.progress-dialog .bar').addClass('progress-bar-striped active'); + }).catch(function(e) { if (e.name === 'HTTPError' && e.code == 411) { $('.progress-dialog').hide(); diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 7b8c3ae2f..caba9cb2a 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -188,6 +188,7 @@ eventTarget.dispatchEvent(ev); contactDetails = contactBuffer.next(); } + eventTarget.dispatchEvent(new Event('textsecure:contactsync')); }); }, handleGroups: function(groups) { diff --git a/options.html b/options.html index d3afc2481..533e4dad7 100644 --- a/options.html +++ b/options.html @@ -114,7 +114,7 @@
-
+
Sorry, you have too many devices registered already. Try removing some.