From 7b2d3b1df0780a26e70d523e3dbdf3b4cf714f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 2 Nov 2016 10:52:04 -0300 Subject: [PATCH] add rate card flag --- src/js/controllers/feedback/rateAppStore.js | 1 - src/js/controllers/feedback/sendFeedback.js | 2 +- src/js/controllers/feedback/thanks.js | 9 +- src/js/controllers/tab-home.js | 163 +++++++++++--------- src/js/services/storageService.js | 8 + www/views/feedback/rateAppStore.html | 4 +- www/views/feedback/thanks.html | 2 +- www/views/tab-home.html | 6 +- 8 files changed, 112 insertions(+), 83 deletions(-) diff --git a/src/js/controllers/feedback/rateAppStore.js b/src/js/controllers/feedback/rateAppStore.js index 58377d0a2..3bc49f140 100644 --- a/src/js/controllers/feedback/rateAppStore.js +++ b/src/js/controllers/feedback/rateAppStore.js @@ -2,7 +2,6 @@ angular.module('copayApp.controllers').controller('rateAppStoreController', function($scope, $state, $stateParams, externalLinkService, configService, gettextCatalog, platformInfo) { $scope.score = parseInt($stateParams.score); - $scope.isCordova = platformInfo.isCordova; var isAndroid = platformInfo.isAndroid; var isIOS = platformInfo.isIOS; var isWP = platformInfo.isWP; diff --git a/src/js/controllers/feedback/sendFeedback.js b/src/js/controllers/feedback/sendFeedback.js index d53d3cef3..cce2b9d06 100644 --- a/src/js/controllers/feedback/sendFeedback.js +++ b/src/js/controllers/feedback/sendFeedback.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('sendFeedbackController', function($scope, $state, $timeout, $stateParams, gettextCatalog) { +angular.module('copayApp.controllers').controller('sendFeedbackController', function($scope, $state, $stateParams, gettextCatalog) { $scope.score = parseInt($stateParams.score); switch ($scope.score) { case 1: diff --git a/src/js/controllers/feedback/thanks.js b/src/js/controllers/feedback/thanks.js index 31c445468..0ccdae254 100644 --- a/src/js/controllers/feedback/thanks.js +++ b/src/js/controllers/feedback/thanks.js @@ -1,13 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('thanksController', function($scope, $state, $stateParams, platformInfo, configService) { +angular.module('copayApp.controllers').controller('thanksController', function($scope, $stateParams, configService, storageService) { $scope.score = parseInt($stateParams.score); $scope.skip = $stateParams.skip && $scope.score == 5; + storageService.setRateCardFlag('true', function() {}); $scope.$on("$ionicView.beforeEnter", function(event, data) { - if (platformInfo.isCordova) { - var config = configService.getSync(); - window.plugins.socialsharing.share(config.download.url, null, null, null); - } + var config = configService.getSync(); + window.plugins.socialsharing.share(config.download.url, null, null, null); }); }); diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 1d1005e97..be2c5d8b9 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -18,27 +18,107 @@ angular.module('copayApp.controllers').controller('tabHomeController', startupService.ready(); }); - if (!$scope.homeTip) { - storageService.getHomeTipAccepted(function(error, value) { - $scope.homeTip = (value == 'accepted') ? false : true; - }); - } + $scope.$on("$ionicView.beforeEnter", function(event, data) { + if (!$scope.homeTip) { + storageService.getHomeTipAccepted(function(error, value) { + $scope.homeTip = (value == 'accepted') ? false : true; + }); + } - if ($scope.isNW) { - latestReleaseService.checkLatestRelease(function(err, newRelease) { - if (err) { - $log.warn(err); - return; - } + if ($scope.isNW) { + latestReleaseService.checkLatestRelease(function(err, newRelease) { + if (err) { + $log.warn(err); + return; + } - if (newRelease) $scope.newRelease = true; + if (newRelease) $scope.newRelease = true; + }); + } + + $scope.hideRateCard = $stateParams.fromAppRate || !$scope.isCordova; + if (!$scope.hideRateCard) { + storageService.getRateCardFlag(function(error, value) { + $scope.hideRateCard = (value == 'true') ? true : false; + }); + } + }); + + $scope.$on("$ionicView.enter", function(event, data) { + updateAllWallets(); + + addressbookService.list(function(err, ab) { + if (err) $log.error(err); + $scope.addressbook = ab || {}; }); - } + + listeners = [ + $rootScope.$on('bwsEvent', function(e, walletId, type, n) { + var wallet = profileService.getWallet(walletId); + updateWallet(wallet); + if ($scope.recentTransactionsEnabled) getNotifications(); + }), + $rootScope.$on('Local/TxAction', function(e, walletId) { + $log.debug('Got action for wallet ' + walletId); + var wallet = profileService.getWallet(walletId); + updateWallet(wallet); + if ($scope.recentTransactionsEnabled) getNotifications(); + }) + ]; + + configService.whenAvailable(function() { + nextStep(function() { + var config = configService.getSync(); + var isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova; + + $scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp; + $scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp; + $scope.amazonEnabled = config.amazon.enabled; + $scope.bitpayCardEnabled = config.bitpayCard.enabled; + + var buyAndSellEnabled = !$scope.externalServices.BuyAndSell && ($scope.glideraEnabled || $scope.coinbaseEnabled); + var amazonEnabled = !$scope.externalServices.AmazonGiftCards && $scope.amazonEnabled; + var bitpayCardEnabled = !$scope.externalServices.BitpayCard && $scope.bitpayCardEnabled; + + $scope.nextStepEnabled = buyAndSellEnabled || amazonEnabled || bitpayCardEnabled; + $scope.recentTransactionsEnabled = config.recentTransactions.enabled; + + if ($scope.recentTransactionsEnabled) getNotifications(); + + if ($scope.bitpayCardEnabled) bitpayCardCache(); + $timeout(function() { + $ionicScrollDelegate.resize(); + $scope.$apply(); + }, 10); + }); + }); + }); + + $scope.$on("$ionicView.leave", function(event, data) { + lodash.each(listeners, function(x) { + x(); + }); + }); + + $scope.$on("$ionicView.leave", function(event, data) { + lodash.each(listeners, function(x) { + x(); + }); + }); $scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) { externalLinkService.open(url, optIn, title, message, okText, cancelText); }; + $scope.hideCard = function() { + storageService.setRateCardFlag('true', function() { + $scope.hideRateCard = true; + $timeout(function() { + $scope.$apply(); + }) + }); + } + $scope.setScore = function(score) { $scope.score = score; switch ($scope.score) { @@ -232,61 +312,4 @@ angular.module('copayApp.controllers').controller('tabHomeController', }, 300); updateAllWallets(); }; - - $scope.$on("$ionicView.beforeEnter", function(event, data) { - updateAllWallets(); - - addressbookService.list(function(err, ab) { - if (err) $log.error(err); - $scope.addressbook = ab || {}; - }); - - listeners = [ - $rootScope.$on('bwsEvent', function(e, walletId, type, n) { - var wallet = profileService.getWallet(walletId); - updateWallet(wallet); - if ($scope.recentTransactionsEnabled) getNotifications(); - }), - $rootScope.$on('Local/TxAction', function(e, walletId) { - $log.debug('Got action for wallet ' + walletId); - var wallet = profileService.getWallet(walletId); - updateWallet(wallet); - if ($scope.recentTransactionsEnabled) getNotifications(); - }) - ]; - - configService.whenAvailable(function() { - nextStep(function() { - var config = configService.getSync(); - var isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova; - - $scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp; - $scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp; - $scope.amazonEnabled = config.amazon.enabled; - $scope.bitpayCardEnabled = config.bitpayCard.enabled; - - var buyAndSellEnabled = !$scope.externalServices.BuyAndSell && ($scope.glideraEnabled || $scope.coinbaseEnabled); - var amazonEnabled = !$scope.externalServices.AmazonGiftCards && $scope.amazonEnabled; - var bitpayCardEnabled = !$scope.externalServices.BitpayCard && $scope.bitpayCardEnabled; - - $scope.nextStepEnabled = buyAndSellEnabled || amazonEnabled || bitpayCardEnabled; - $scope.recentTransactionsEnabled = config.recentTransactions.enabled; - - if ($scope.recentTransactionsEnabled) getNotifications(); - - if ($scope.bitpayCardEnabled) bitpayCardCache(); - $timeout(function() { - $ionicScrollDelegate.resize(); - $scope.$apply(); - }, 10); - }); - }); - }); - - $scope.$on("$ionicView.leave", function(event, data) { - lodash.each(listeners, function(x) { - x(); - }); - }); - }); diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 4184f8454..e68f28df0 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -203,6 +203,14 @@ angular.module('copayApp.services') storage.set('homeTip', val, cb); }; + root.getRateCardFlag = function(cb) { + storage.get('rateCardFlag', cb); + }; + + root.setRateCardFlag = function(val, cb) { + storage.set('rateCardFlag', val, cb); + }; + root.setHideBalanceFlag = function(walletId, val, cb) { storage.set('hideBalance-' + walletId, val, cb); }; diff --git a/www/views/feedback/rateAppStore.html b/www/views/feedback/rateAppStore.html index 8ca841b05..eca714e32 100644 --- a/www/views/feedback/rateAppStore.html +++ b/www/views/feedback/rateAppStore.html @@ -22,11 +22,11 @@ Would you be willing to rate BitPay Wallet in the app store?
-
diff --git a/www/views/feedback/thanks.html b/www/views/feedback/thanks.html index 3922cedad..a76b5afda 100644 --- a/www/views/feedback/thanks.html +++ b/www/views/feedback/thanks.html @@ -1,7 +1,7 @@ - diff --git a/www/views/tab-home.html b/www/views/tab-home.html index 4ce90293b..005d0cb75 100644 --- a/www/views/tab-home.html +++ b/www/views/tab-home.html @@ -10,13 +10,13 @@ spinner="ios-small" on-refresh="onRefresh()"> -
+
An update to this app is available
-
+
How do you like BitPay Wallet? - +