Feat: new setting to notify when a transaction is confirmed

This commit is contained in:
Gabriel Masclef 2017-07-13 11:12:15 -03:00
commit c9cdd91741
6 changed files with 46 additions and 9 deletions

View file

@ -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);
};

View file

@ -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,

View file

@ -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 = {