diff --git a/public/index.html b/public/index.html index cd27bc35e..a913a4c5d 100644 --- a/public/index.html +++ b/public/index.html @@ -28,9 +28,9 @@
-
-
+
+ +
diff --git a/public/views/copayers.html b/public/views/copayers.html index c2e337d04..4562274af 100644 --- a/public/views/copayers.html +++ b/public/views/copayers.html @@ -1,5 +1,5 @@
+ ng-if="!index.clientError">
diff --git a/public/views/createProfile.html b/public/views/createProfile.html index ca58a33d1..6f73a3706 100644 --- a/public/views/createProfile.html +++ b/public/views/createProfile.html @@ -5,16 +5,11 @@ Copay
-
-
-

Warning

-
-

You don’t have an internet connection active. Copay needs connection to create a wallet

-
-
+
+ {{(cp.error)|translate}}. Retrying...
- -
+ +
Creating wallet...
diff --git a/public/views/history.html b/public/views/history.html index f49075310..a6cb99f8f 100644 --- a/public/views/history.html +++ b/public/views/history.html @@ -3,7 +3,15 @@
Getting transactions... - No transactions yet + +
+
+ +
+ Could not fetch transaction history + +
+ No transactions yet
diff --git a/public/views/includes/offline.html b/public/views/includes/offline.html index f3c9e55ea..b732ac84d 100644 --- a/public/views/includes/offline.html +++ b/public/views/includes/offline.html @@ -4,8 +4,8 @@
-

{{'No internet connection'|translate}}

-
{{'Copay needs connection to run basic functions'|translate}}
+

{{'Could not connect to Wallet Service'|translate}}

+
{{'Trying to reconnnect...'|translate}}
diff --git a/public/views/includes/sidebar.html b/public/views/includes/sidebar.html index d2628f6ac..cabc0dc1a 100644 --- a/public/views/includes/sidebar.html +++ b/public/views/includes/sidebar.html @@ -15,7 +15,7 @@
{{item.m}} of {{item.n}}
-
  • +
  • diff --git a/public/views/receive.html b/public/views/receive.html index 3591a09e3..0eacc0ec6 100644 --- a/public/views/receive.html +++ b/public/views/receive.html @@ -34,6 +34,15 @@
    +
    +
    + +
    + + {{receive.error|translate}} + +
    +
    @@ -56,7 +65,7 @@
    -
    +
    diff --git a/public/views/send.html b/public/views/send.html index ae8f374f0..282e3289d 100644 --- a/public/views/send.html +++ b/public/views/send.html @@ -1,4 +1,4 @@ -
    +

    @@ -152,6 +152,4 @@

    -
    Checking your internet connection...
    -
    diff --git a/public/views/walletHome.html b/public/views/walletHome.html index f86194a4f..2cd6bfbd8 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -1,6 +1,7 @@
    +
    @@ -39,6 +40,15 @@
    +
    +
    + + + Could not update Wallet + +
    +
    +
    diff --git a/src/css/mobile.css b/src/css/mobile.css index 92cc05557..c2e8628e5 100644 --- a/src/css/mobile.css +++ b/src/css/mobile.css @@ -476,8 +476,10 @@ a.pin-button:active { .dr-notification-wrapper.offline { position: absolute; - top: 45px; - z-index: 11; + top: 0px; + z-index: 2000; + opacity: 1.0 !important; + background-color: #2C3E50; } .dr-notification-wrapper.client-error { diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 27fa37b68..bad589b43 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -69,8 +69,13 @@ angular.module('copayApp.controllers').controller('indexController', function($r var get = function(cb) { if (walletStatus) return cb(null, walletStatus); - else - return fc.getStatus(cb); + else { + self.updateError = false; + return fc.getStatus(function(err, ret) { + if (err) self.updateError = true; + return cb(err, ret); + }); + } }; var fc = profileService.focusedClient; @@ -144,6 +149,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r $timeout(function() { self.setOngoingProcess('updatingTxHistory', true); $log.debug('Updating Transaction History'); + self.txHistoryError = false; fc.getTxHistory({ skip: self.skipHistory, limit: self.limitHistory + 1 @@ -152,8 +158,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r if (err) { $log.debug('TxHistory ERROR:', err); $scope.$emit('Local/ClientError', err); - } - else { + self.txHistoryError = true; + } else { $log.debug('Wallet Transaction History:', txs); self.skipHistory = self.skipHistory + self.limitHistory; self.setTxHistory(txs); @@ -390,14 +396,19 @@ angular.module('copayApp.controllers').controller('indexController', function($r go.walletHome(); }); - $rootScope.$on('Local/OnLine', function(event) { - self.isOffLine = false; - self.updateAll(); - self.updateTxHistory(); + lodash.each(['Local/Online', 'Local/Resume'], function(eventName) { + $rootScope.$on(eventName, function(event) { + $log.debug('### Online event'); + self.isOffline = false; + self.updateAll(); + self.updateTxHistory(); + }); }); - $rootScope.$on('Local/OffLine', function(event) { - self.isOffLine = true; + $rootScope.$on('Local/Offline', function(event) { + $log.debug('========== Offline event'); + self.isOffline = true; + $rootScope.$apply(); }); $rootScope.$on('Local/BackupDone', function(event) { @@ -424,6 +435,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r if (err.code && err.code === 'NOTAUTHORIZED') { // Show not error, just redirect to home (where the recreate option is shown) go.walletHome(); + } else if (err && err.cors == 'rejected') { + $log.debug('CORS error:', err); } else { self.clientError = err; } @@ -506,7 +519,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r $rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) { self.askPassword = { isSetup: isSetup, - callback: function (err, pass) { + callback: function(err, pass) { self.askPassword = null; return cb(err, pass); }, diff --git a/src/js/controllers/receive.js b/src/js/controllers/receive.js index 833db0804..fddd93ff4 100644 --- a/src/js/controllers/receive.js +++ b/src/js/controllers/receive.js @@ -16,15 +16,17 @@ angular.module('copayApp.controllers').controller('receiveController', this.newAddress = function() { self.generatingAddress = true; + self.error = null; fc.createAddress(function(err, addr) { + self.generatingAddress = false; if (err) { $log.debug('Creating address ERROR:', err); $scope.$emit('Local/ClientError', err); + self.error='Could not generate address'; } else { self.addr = addr.address; storageService.storeLastAddress(fc.credentials.walletId, addr.address, function() {}); } - self.generatingAddress = false; $scope.$digest(); }); }; diff --git a/src/js/init.js b/src/js/init.js index e5dc0ab5e..104d44406 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -23,13 +23,24 @@ angular.element(document).ready(function() { window.location = '#/'; } }, false); - + document.addEventListener('resume', function() { + window.location = '#/cordova/resume'; setTimeout(function() { window.ignoreMobilePause = false; }, 100); }, false); + // We are not emitting here, since when the BWS socket reconnects, + // update will be triggered + // document.addEventListener('offline', function() { + // window.location = '#/cordova/offline'; + // }, false); + // + // document.addEventListener("online", function() { + // window.location = '#/cordoba/online'; + // }, false); + document.addEventListener('backbutton', function() { window.location = '#/walletHome'; }, false); @@ -38,13 +49,7 @@ angular.element(document).ready(function() { window.location = '#/preferences'; }, false); - document.addEventListener('offline', function() { - window.location = '#/network/offline'; - }, false); - document.addEventListener("online", function() { - window.location = '#/network/online'; - }, false); setTimeout(function() { navigator.splashscreen.hide(); diff --git a/src/js/routes.js b/src/js/routes.js index 1a20750b8..156110fec 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -322,8 +322,8 @@ angular } } }) - - .state('preferencesAltCurrency', { + + .state('preferencesAltCurrency', { url: '/preferencesAltCurrency', templateUrl: 'views/preferencesAltCurrency.html', walletShouldBeComplete: true, @@ -409,33 +409,36 @@ angular }) .state('add', { - url: '/add', - needProfile: true, - views: { - 'main': { - templateUrl: 'views/add.html' - }, - 'topbar': { - templateUrl: 'views/includes/topbar.html', - controller: function($scope) { - $scope.titleSection = 'Add wallet'; - $scope.goBackToState = 'walletHome'; + url: '/add', + needProfile: true, + views: { + 'main': { + templateUrl: 'views/add.html' + }, + 'topbar': { + templateUrl: 'views/includes/topbar.html', + controller: function($scope) { + $scope.titleSection = 'Add wallet'; + $scope.goBackToState = 'walletHome'; + } } } - } - }) - .state('network', { - url: '/network/:status', + }) + .state('cordova', { + url: '/cordova/:status', views: { 'main': { controller: function($scope, $stateParams, go) { switch ($stateParams.status) { - case 'online': - $scope.$emit('Local/OnLine'); - break; - case 'offline': - $scope.$emit('Local/OffLine'); + case 'resume': + $scope.$emit('Local/Resume'); break; + // case 'online': + // // $scope.$emit('Local/Online'); + // break; + // case 'offline': + // // $scope.$emit('Local/Offline'); + // break; }; go.walletHome(); } @@ -491,8 +494,7 @@ angular if (pageWeight[fromState.name] > pageWeight[toState.name]) { $rootScope.$emit('Animation/SwipeRight'); - } - else if (pageWeight[fromState.name] < pageWeight[toState.name]) { + } else if (pageWeight[fromState.name] < pageWeight[toState.name]) { $rootScope.$emit('Animation/SwipeLeft'); } diff --git a/src/js/services/configService.js b/src/js/services/configService.js index 7e4bff118..2474a95bc 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -13,6 +13,7 @@ angular.module('copayApp.services').factory('configService', function(localStora // Bitcore wallet service URL bws: { url: 'http://162.242.245.33:3004/bws/api', +// url: 'http://localhost:3001/bws/api', }, // insight diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 7d5d1496e..3e570ed68 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -60,6 +60,20 @@ angular.module('copayApp.services') root.walletClients[credentials.walletId] = client; client.removeAllListeners(); + + client.on('reconnect', function() { + if (root.focusedClient.credentials.walletId == client.credentials.walletId) { + $rootScope.$emit('Local/Online'); + } + }); + + + client.on('reconnecting', function() { + if (root.focusedClient.credentials.walletId == client.credentials.walletId) { + $rootScope.$emit('Local/Offline'); + } + }); + client.on('notification', function(n) { $log.debug('BWC Notification:', n); notificationService.newBWCNotification(n,