From c9cdd91741e8c0743aa15431f3d7dbba5c1c1349 Mon Sep 17 00:00:00 2001 From: Gabriel Masclef Date: Thu, 13 Jul 2017 11:12:15 -0300 Subject: [PATCH 1/3] Feat: new setting to notify when a transaction is confirmed --- src/js/controllers/confirm.js | 7 ++++++- src/js/controllers/preferencesNotifications.js | 17 +++++++++++++++++ src/js/controllers/tx-details.js | 4 +++- src/js/services/configService.js | 4 ++++ www/views/preferencesNotifications.html | 7 +++++++ www/views/tx-details.html | 16 +++++++++------- 6 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index f688ed3fc..ed3d39e29 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError) { +angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError, txConfirmNotification) { var countDown = null; var CONFIRM_LIMIT_USD = 20; @@ -509,6 +509,11 @@ angular.module('copayApp.controllers').controller('confirmController', function( walletService.publishAndSign(wallet, txp, function(err, txp) { if (err) return setSendError(err); + if (config.notifyIfTxConfirmed && config.notifyIfTxConfirmed.enabled) { + txConfirmNotification.subscribe(wallet, { + txid: txp.id + }); + } }, onSendStatusChange); }; diff --git a/src/js/controllers/preferencesNotifications.js b/src/js/controllers/preferencesNotifications.js index 28371e319..bb407e100 100644 --- a/src/js/controllers/preferencesNotifications.js +++ b/src/js/controllers/preferencesNotifications.js @@ -12,6 +12,11 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr value: config.pushNotificationsEnabled }; + var isNotifyTxEnabled = config.notifyIfTxConfirmed ? config.notifyIfTxConfirmed.enabled : false; + $scope.notifyIfTxConfirmed = { + value: isNotifyTxEnabled + }; + $scope.latestEmail = { value: emailService.getEmailIfEnabled() }; @@ -42,6 +47,18 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr }); }; + $scope.notifyIfTxConfirmedChange = function() { + if (!$scope.pushNotifications) return; + var opts = { + notifyIfTxConfirmed: { + enabled: $scope.notifyIfTxConfirmed.value + } + }; + configService.set(opts, function(err) { + if (err) $log.debug(err); + }); + }; + $scope.emailNotificationsChange = function() { var opts = { enabled: $scope.emailNotifications.value, diff --git a/src/js/controllers/tx-details.js b/src/js/controllers/tx-details.js index 8435447d1..85714850f 100644 --- a/src/js/controllers/tx-details.js +++ b/src/js/controllers/tx-details.js @@ -1,9 +1,10 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $ionicHistory, $scope, $timeout, walletService, lodash, gettextCatalog, profileService, externalLinkService, popupService, ongoingProcess, txFormatService, txConfirmNotification, feeService) { +angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $ionicHistory, $scope, $timeout, walletService, lodash, gettextCatalog, profileService, externalLinkService, popupService, ongoingProcess, txFormatService, txConfirmNotification, feeService, configService) { var txId; var listeners = []; + var config = configService.getSync(); $scope.$on("$ionicView.beforeEnter", function(event, data) { txId = data.stateParams.txid; @@ -12,6 +13,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.color = $scope.wallet.color; $scope.copayerId = $scope.wallet.credentials.copayerId; $scope.isShared = $scope.wallet.credentials.n > 1; + $scope.notifyIfTxConfirmed = config.notifyIfTxConfirmed ? config.notifyIfTxConfirmed.enabled : false; txConfirmNotification.checkIfEnabled(txId, function(res) { $scope.txNotification = { diff --git a/src/js/services/configService.js b/src/js/services/configService.js index e4521296a..b736dcae5 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -80,6 +80,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer pushNotificationsEnabled: true, + notifyIfTxConfirmed: { + enabled: true, + }, + emailNotifications: { enabled: false, }, diff --git a/www/views/preferencesNotifications.html b/www/views/preferencesNotifications.html index baf9e7a05..d67e804c8 100644 --- a/www/views/preferencesNotifications.html +++ b/www/views/preferencesNotifications.html @@ -43,6 +43,13 @@ + +
+ + Notify me when confirm transactions + +
+ diff --git a/www/views/tx-details.html b/www/views/tx-details.html index 6ef243116..ff1812355 100644 --- a/www/views/tx-details.html +++ b/www/views/tx-details.html @@ -108,13 +108,15 @@ This transaction amount is too small compared to current Bitcoin network fees. S - - Notify me if confirmed - +
+ + Notify me if confirmed + +
Timeline
From 372b4697e7fdebb7387b72cb0566389e9ab9b40a Mon Sep 17 00:00:00 2001 From: Gabriel Masclef Date: Fri, 14 Jul 2017 10:18:36 -0300 Subject: [PATCH 2/3] Transaction id fixed --- src/js/controllers/confirm.js | 2 +- www/views/preferencesNotifications.html | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index ed3d39e29..e5022ab00 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -511,7 +511,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( if (err) return setSendError(err); if (config.notifyIfTxConfirmed && config.notifyIfTxConfirmed.enabled) { txConfirmNotification.subscribe(wallet, { - txid: txp.id + txid: txp.txid }); } }, onSendStatusChange); diff --git a/www/views/preferencesNotifications.html b/www/views/preferencesNotifications.html index d67e804c8..8673138c7 100644 --- a/www/views/preferencesNotifications.html +++ b/www/views/preferencesNotifications.html @@ -19,6 +19,12 @@
+
+ + Notify me when transactions are confirmed + +
+ Enable email notifications @@ -44,11 +50,6 @@ -
- - Notify me when confirm transactions - -
From a3949efbfd002476448cf4e0b2ca433ca8f40993 Mon Sep 17 00:00:00 2001 From: Gabriel Masclef Date: Fri, 14 Jul 2017 15:45:18 -0300 Subject: [PATCH 3/3] Names fixes --- src/js/controllers/confirm.js | 2 +- src/js/controllers/preferencesNotifications.js | 12 ++++++------ src/js/controllers/tx-details.js | 2 +- src/js/services/configService.js | 2 +- www/views/preferencesNotifications.html | 4 ++-- www/views/tx-details.html | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index e5022ab00..49e84cb89 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -509,7 +509,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( walletService.publishAndSign(wallet, txp, function(err, txp) { if (err) return setSendError(err); - if (config.notifyIfTxConfirmed && config.notifyIfTxConfirmed.enabled) { + if (config.confirmedTxsNotifications && config.confirmedTxsNotifications.enabled) { txConfirmNotification.subscribe(wallet, { txid: txp.txid }); diff --git a/src/js/controllers/preferencesNotifications.js b/src/js/controllers/preferencesNotifications.js index bb407e100..3d78e98db 100644 --- a/src/js/controllers/preferencesNotifications.js +++ b/src/js/controllers/preferencesNotifications.js @@ -12,9 +12,9 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr value: config.pushNotificationsEnabled }; - var isNotifyTxEnabled = config.notifyIfTxConfirmed ? config.notifyIfTxConfirmed.enabled : false; - $scope.notifyIfTxConfirmed = { - value: isNotifyTxEnabled + var isConfirmedTxsNotificationsEnabled = config.confirmedTxsNotifications ? config.confirmedTxsNotifications.enabled : false; + $scope.confirmedTxsNotifications = { + value: isConfirmedTxsNotificationsEnabled }; $scope.latestEmail = { @@ -47,11 +47,11 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr }); }; - $scope.notifyIfTxConfirmedChange = function() { + $scope.confirmedTxsNotificationsChange = function() { if (!$scope.pushNotifications) return; var opts = { - notifyIfTxConfirmed: { - enabled: $scope.notifyIfTxConfirmed.value + confirmedTxsNotifications: { + enabled: $scope.confirmedTxsNotifications.value } }; configService.set(opts, function(err) { diff --git a/src/js/controllers/tx-details.js b/src/js/controllers/tx-details.js index 85714850f..0c277e469 100644 --- a/src/js/controllers/tx-details.js +++ b/src/js/controllers/tx-details.js @@ -13,7 +13,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.color = $scope.wallet.color; $scope.copayerId = $scope.wallet.credentials.copayerId; $scope.isShared = $scope.wallet.credentials.n > 1; - $scope.notifyIfTxConfirmed = config.notifyIfTxConfirmed ? config.notifyIfTxConfirmed.enabled : false; + $scope.txsUnsubscribedForNotifications = config.confirmedTxsNotifications ? !config.confirmedTxsNotifications.enabled : true; txConfirmNotification.checkIfEnabled(txId, function(res) { $scope.txNotification = { diff --git a/src/js/services/configService.js b/src/js/services/configService.js index b736dcae5..c128208c4 100644 --- a/src/js/services/configService.js +++ b/src/js/services/configService.js @@ -80,7 +80,7 @@ angular.module('copayApp.services').factory('configService', function(storageSer pushNotificationsEnabled: true, - notifyIfTxConfirmed: { + confirmedTxsNotifications: { enabled: true, }, diff --git a/www/views/preferencesNotifications.html b/www/views/preferencesNotifications.html index 8673138c7..a2d7ee725 100644 --- a/www/views/preferencesNotifications.html +++ b/www/views/preferencesNotifications.html @@ -19,8 +19,8 @@ -
- +
+ Notify me when transactions are confirmed
diff --git a/www/views/tx-details.html b/www/views/tx-details.html index ff1812355..de7ab9977 100644 --- a/www/views/tx-details.html +++ b/www/views/tx-details.html @@ -108,7 +108,7 @@ This transaction amount is too small compared to current Bitcoin network fees. S
-
+