From 4198987723c4b7a4ce6484e08d10cec7996267af Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 9 Feb 2016 16:21:42 -0800 Subject: [PATCH] Display a message when provisioning socket fails Fixes #464 // FREEBIE --- _locales/en/messages.json | 4 ++++ js/options.js | 3 ++- js/views/install_view.js | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index c476fbf8..8ba623b9 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -154,6 +154,10 @@ "message": "Connecting...", "description": "Displayed when waiting for the QR Code" }, + "installConnectionFailed": { + "message": "Failed to connect to server.", + "description": "Displayed when we can't connect to the server." + }, "installGeneratingKeys": { "message": "Generating Keys" }, diff --git a/js/options.js b/js/options.js index b43401a1..49eaec39 100644 --- a/js/options.js +++ b/js/options.js @@ -44,7 +44,8 @@ view.showSync(); }).catch(function(e) { if (e.message === 'websocket closed') { - init(); + view.showConnectionError(); + setTimeout(init, 10000); } else if (e.name === 'HTTPError' && e.code == 411) { view.showTooManyDevices(); } diff --git a/js/views/install_view.js b/js/views/install_view.js index eaaa900d..185d0117 100644 --- a/js/views/install_view.js +++ b/js/views/install_view.js @@ -44,8 +44,8 @@ this.$('#qr').text(i18n("installConnecting")); }, setProvisioningUrl: function(url) { - this.$('#qr').html(''); - new QRCode(this.$('#qr')[0]).makeCode(url); + this.$('#qr').html(''); + new QRCode(this.$('#qr')[0]).makeCode(url); }, confirmNumber: function(number) { var parsed = libphonenumber.parse(number); @@ -88,6 +88,9 @@ }, showTooManyDevices: function() { this.selectStep('TooManyDevices'); + }, + showConnectionError: function() { + this.$('#qr').text(i18n("installConnectionFailed")); } }); })();