From effbd098a6cd0bb8363fce5a48631d8f698df1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Mon, 29 Aug 2016 11:56:31 -0300 Subject: [PATCH] onboarding allow push notifications --- public/views/onboarding/collectEmail.html | 4 +-- public/views/onboarding/notifications.html | 2 +- .../controllers/onboarding/backupRequest.js | 2 +- .../controllers/onboarding/backupWarning.js | 2 +- src/js/controllers/onboarding/collectEmail.js | 10 ++++-- .../controllers/onboarding/notifications.js | 6 ++-- src/js/controllers/onboarding/tour.js | 2 +- src/js/services/profileService.js | 36 ++++++++++--------- 8 files changed, 36 insertions(+), 28 deletions(-) diff --git a/public/views/onboarding/collectEmail.html b/public/views/onboarding/collectEmail.html index b03f80f7f..a539eaaa0 100644 --- a/public/views/onboarding/collectEmail.html +++ b/public/views/onboarding/collectEmail.html @@ -1,7 +1,7 @@ - + - diff --git a/public/views/onboarding/notifications.html b/public/views/onboarding/notifications.html index cb97ea4cd..555a06d08 100644 --- a/public/views/onboarding/notifications.html +++ b/public/views/onboarding/notifications.html @@ -1,5 +1,5 @@ - +

Push Notifications diff --git a/src/js/controllers/onboarding/backupRequest.js b/src/js/controllers/onboarding/backupRequest.js index 8b22651a6..60ae381f2 100644 --- a/src/js/controllers/onboarding/backupRequest.js +++ b/src/js/controllers/onboarding/backupRequest.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('backupRequestController', function($rootScope, $scope, $state, $ionicPopup, $stateParams, profileService, walletService) { +angular.module('copayApp.controllers').controller('backupRequestController', function($scope, $state, $ionicPopup) { $scope.openPopup = function() { var backupLaterPopup = $ionicPopup.show({ diff --git a/src/js/controllers/onboarding/backupWarning.js b/src/js/controllers/onboarding/backupWarning.js index abde7a7d3..f0b7c4978 100644 --- a/src/js/controllers/onboarding/backupWarning.js +++ b/src/js/controllers/onboarding/backupWarning.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('backupWarningController', function($rootScope, $scope, $state, $ionicPopup, $stateParams, profileService, walletService) { +angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $ionicPopup, profileService) { $scope.openPopup = function() { var backupWarningPopup = $ionicPopup.show({ diff --git a/src/js/controllers/onboarding/collectEmail.js b/src/js/controllers/onboarding/collectEmail.js index 2d19a1a2f..e92aa6cc9 100644 --- a/src/js/controllers/onboarding/collectEmail.js +++ b/src/js/controllers/onboarding/collectEmail.js @@ -1,6 +1,11 @@ 'use strict'; -angular.module('copayApp.controllers').controller('collectEmailController', function($rootScope, $scope, $state, $stateParams, $timeout, $ionicModal, profileService, walletService) { +angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $stateParams, profileService, walletService, platformInfo) { + + $scope.skip = function() { + if (!platformInfo.isCordova) $state.go('onboarding.backupRequest'); + else $state.go('onboarding.notifications'); + } $scope.save = function(form) { var wallet = profileService.getWallet($stateParams.walletId); @@ -10,7 +15,8 @@ angular.module('copayApp.controllers').controller('collectEmailController', func email: email, }, function(err) { if (err) $log.warn(err); - $state.go('onboarding.notifications'); + if (!platformInfo.isCordova) $state.go('onboarding.backupRequest'); + else $state.go('onboarding.notifications'); }); }; diff --git a/src/js/controllers/onboarding/notifications.js b/src/js/controllers/onboarding/notifications.js index dabb17eb3..2b40cd65a 100644 --- a/src/js/controllers/onboarding/notifications.js +++ b/src/js/controllers/onboarding/notifications.js @@ -1,11 +1,9 @@ 'use strict'; -angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, platformInfo) { - - if (!platformInfo.isCordova) $state.go('onboarding.backupRequest'); +angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, profileService) { $scope.allowNotif = function() { - // T O D O + profileService.pushNotificationsInit(); $state.go('onboarding.backupRequest'); } diff --git a/src/js/controllers/onboarding/tour.js b/src/js/controllers/onboarding/tour.js index 2f361158c..662b0431d 100644 --- a/src/js/controllers/onboarding/tour.js +++ b/src/js/controllers/onboarding/tour.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.controllers').controller('tourController', - function($scope, $stateParams, $state, $log, $timeout, ongoingProcess, storageService, profileService) { + function($scope, $state, $log, $timeout, ongoingProcess, profileService) { $scope.init = function() { diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 12d55b3e5..f50a6cd29 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -16,19 +16,23 @@ angular.module('copayApp.services') root.profile = null; - Object.defineProperty(root, "focusedClient", { - get: function () { throw "focusedClient is not used any more" }, - set: function () { throw "focusedClient is not used any more" } + Object.defineProperty(root, "focusedClient", { + get: function() { + throw "focusedClient is not used any more" + }, + set: function() { + throw "focusedClient is not used any more" + } }); - - root.wallet = {}; // decorated version of client + + root.wallet = {}; // decorated version of client root.updateWalletSettings = function(wallet) { var defaults = configService.getDefaults(); var config = configService.getSync(); - wallet.usingCustomBWS = config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url); + wallet.usingCustomBWS = config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url); wallet.name = config.aliasFor[wallet.id] || wallet.credentials.walletName; wallet.color = config.colorFor[wallet.id] || '#4A90E2'; @@ -69,7 +73,7 @@ angular.module('copayApp.services') // notification? - // TODO (put this in wallet ViewModel) + // TODO (put this in wallet ViewModel) if (wallet.cachedStatus) wallet.cachedStatus.isValid = false; @@ -99,7 +103,7 @@ angular.module('copayApp.services') } wallet.setNotificationsInterval(UPDATE_PERIOD); wallet.openWallet(function(err) { - if (wallet.status !== true) + if (wallet.status !== true) $log.log('Wallet + ' + walletId + ' status:' + wallet.status) }); }); @@ -107,7 +111,7 @@ angular.module('copayApp.services') $rootScope.$on('Local/SettingsUpdated', function(e, walletId) { if (!walletId || walletId == wallet.id) { - $log.debug('Updating settings for wallet:' + wallet.id); + $log.debug('Updating settings for wallet:' + wallet.id); root.updateWalletSettings(wallet); } }); @@ -159,7 +163,7 @@ angular.module('copayApp.services') if (!credentials.walletId || !credentials.m) return cb('bindWallet should receive credentials JSON'); - // Create the client + // Create the client var getBWSURL = function(walletId) { var config = configService.getSync(); var defaults = configService.getDefaults(); @@ -206,9 +210,6 @@ angular.module('copayApp.services') } bindWallets(function() { - if (usePushNotifications) - root.pushNotificationsInit(); - root.isBound = true; lodash.each(root._queue, function(x) { @@ -224,6 +225,8 @@ angular.module('copayApp.services') if (!val) { return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer')); } + if (usePushNotifications) + root.pushNotificationsInit(); $rootScope.$emit('disclaimerAccepted'); return cb(); }); @@ -716,10 +719,11 @@ angular.module('copayApp.services') ret = lodash.filter(ret, function(w) { return w.isComplete(); }); - } else { - } + } else {} - return lodash.sortBy(ret, [ function(x) { return x.isComplete(); }, 'createdOn']); + return lodash.sortBy(ret, [function(x) { + return x.isComplete(); + }, 'createdOn']); }; return root;