Merge pull request #6408 from Gamboster/feat/notifyTxConfirm

Confirmed transactions notifications as global settings
This commit is contained in:
Javier Donadío 2017-07-14 16:09:27 -03:00 committed by GitHub
commit 875b8d1041
6 changed files with 47 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.confirmedTxsNotifications && config.confirmedTxsNotifications.enabled) {
txConfirmNotification.subscribe(wallet, {
txid: txp.txid
});
}
}, onSendStatusChange);
};

View File

@ -12,6 +12,11 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
value: config.pushNotificationsEnabled
};
var isConfirmedTxsNotificationsEnabled = config.confirmedTxsNotifications ? config.confirmedTxsNotifications.enabled : false;
$scope.confirmedTxsNotifications = {
value: isConfirmedTxsNotificationsEnabled
};
$scope.latestEmail = {
value: emailService.getEmailIfEnabled()
};
@ -42,6 +47,18 @@ angular.module('copayApp.controllers').controller('preferencesNotificationsContr
});
};
$scope.confirmedTxsNotificationsChange = function() {
if (!$scope.pushNotifications) return;
var opts = {
confirmedTxsNotifications: {
enabled: $scope.confirmedTxsNotifications.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.txsUnsubscribedForNotifications = config.confirmedTxsNotifications ? !config.confirmedTxsNotifications.enabled : true;
txConfirmNotification.checkIfEnabled(txId, function(res) {
$scope.txNotification = {

View File

@ -80,6 +80,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer
pushNotificationsEnabled: true,
confirmedTxsNotifications: {
enabled: true,
},
emailNotifications: {
enabled: false,
},

View File

@ -19,6 +19,12 @@
</div>
</div>
<div ng-if="usePushNotifications && pushNotifications.value">
<ion-toggle ng-model="confirmedTxsNotifications.value" toggle-class="toggle-balanced" ng-change="confirmedTxsNotificationsChange()">
<span class="toggle-label" translate>Notify me when transactions are confirmed</span>
</ion-toggle>
</div>
<ion-toggle ng-model="emailNotifications.value" toggle-class="toggle-balanced" ng-change="emailNotificationsChange()">
<span class="toggle-label" translate>Enable email notifications</span>
</ion-toggle>
@ -43,6 +49,8 @@
</button>
</form>
</div>
</div>
</ion-content>
</ion-view>

View File

@ -108,13 +108,15 @@ This transaction amount is too small compared to current Bitcoin network fees. S
</span>
</span>
</div>
<ion-toggle ng-show="!btx.confirmations || btx.confirmations == 0"
class="toggle-unconfirmed"
ng-model="txNotification.value"
toggle-class="toggle-balanced"
ng-change="txConfirmNotificationChange()">
<span class="toggle-label" translate>Notify me if confirmed</span>
</ion-toggle>
<div ng-if="txsUnsubscribedForNotifications">
<ion-toggle ng-show="!btx.confirmations || btx.confirmations == 0"
class="toggle-unconfirmed"
ng-model="txNotification.value"
toggle-class="toggle-balanced"
ng-change="txConfirmNotificationChange()">
<span class="toggle-label" translate>Notify me if confirmed</span>
</ion-toggle>
</div>
<div ng-if="actionList[0]">
<div class="item item-divider" translate>Timeline</div>
<div class="item timeline-item" ng-class="{'action-created' : a.type == 'created' || a.type == 'accept', 'action-rejected' : a.type == 'reject'}" ng-repeat="a in actionList track by $index">