add switch to enable/disable notifications on global setings
This commit is contained in:
parent
f8c5e392f0
commit
b3c59e2cb0
4 changed files with 30 additions and 3 deletions
|
|
@ -48,6 +48,10 @@
|
||||||
<switch id="spend-unconfirmed" name="spendUnconfirmed" ng-model="spendUnconfirmed" class="green right"></switch>
|
<switch id="spend-unconfirmed" name="spendUnconfirmed" ng-model="spendUnconfirmed" class="green right"></switch>
|
||||||
<div translate>Use Unconfirmed Funds</div>
|
<div translate>Use Unconfirmed Funds</div>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<switch id="enable-notifications" name="notifications" ng-model="notifications" class="green right"></switch>
|
||||||
|
<div translate>Enable notifications</div>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h4></h4>
|
<h4></h4>
|
||||||
<ul class="no-bullet m0 ">
|
<ul class="no-bullet m0 ">
|
||||||
|
|
|
||||||
|
|
@ -1197,6 +1197,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.updateAll();
|
self.updateAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$rootScope.$on('Local/EnableNotifications', function(event, vale) {
|
||||||
|
//make suscribe/unsuscribe
|
||||||
|
self.updateAll();
|
||||||
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/FeeLevelUpdated', function(event, level) {
|
$rootScope.$on('Local/FeeLevelUpdated', function(event, level) {
|
||||||
self.setCurrentFeeLevel(level);
|
self.setCurrentFeeLevel(level);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesGlobalController',
|
angular.module('copayApp.controllers').controller('preferencesGlobalController',
|
||||||
function($scope, $rootScope, $log, configService, uxLanguage) {
|
function($scope, $rootScope, $log, configService, uxLanguage) {
|
||||||
|
|
||||||
this.init = function() {
|
this.init = function() {
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
this.unitName = config.wallet.settings.unitName;
|
this.unitName = config.wallet.settings.unitName;
|
||||||
|
|
@ -10,10 +10,11 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController',
|
||||||
this.selectedAlternative = {
|
this.selectedAlternative = {
|
||||||
name: config.wallet.settings.alternativeName,
|
name: config.wallet.settings.alternativeName,
|
||||||
isoCode: config.wallet.settings.alternativeIsoCode
|
isoCode: config.wallet.settings.alternativeIsoCode
|
||||||
};
|
};
|
||||||
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
|
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
|
||||||
$scope.glideraEnabled = config.glidera.enabled;
|
$scope.glideraEnabled = config.glidera.enabled;
|
||||||
$scope.glideraTestnet = config.glidera.testnet;
|
$scope.glideraTestnet = config.glidera.testnet;
|
||||||
|
$scope.notifications = config.notifications ? config.notifications.enabled : true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
|
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
|
||||||
|
|
@ -29,6 +30,19 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var unwatchNotification = $scope.$watch('notifications', function(newVal, oldVal) {
|
||||||
|
if (newVal == oldVal) return;
|
||||||
|
var opts = {
|
||||||
|
notifications: {
|
||||||
|
enabled: newVal
|
||||||
|
}
|
||||||
|
};
|
||||||
|
configService.set(opts, function(err) {
|
||||||
|
$rootScope.$emit('Local/EnableNotifications', opts);
|
||||||
|
if (err) $log.debug(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) {
|
var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) {
|
||||||
if (newVal == oldVal) return;
|
if (newVal == oldVal) return;
|
||||||
var opts = {
|
var opts = {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
||||||
rates: {
|
rates: {
|
||||||
url: 'https://insight.bitpay.com:443/api/rates',
|
url: 'https://insight.bitpay.com:443/api/rates',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
notifications: {
|
||||||
|
enabled: true
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var configCache = null;
|
var configCache = null;
|
||||||
|
|
@ -70,7 +74,7 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
||||||
configCache.wallet.settings.unitCode = defaultConfig.wallet.settings.unitCode;
|
configCache.wallet.settings.unitCode = defaultConfig.wallet.settings.unitCode;
|
||||||
}
|
}
|
||||||
if (!configCache.glidera) {
|
if (!configCache.glidera) {
|
||||||
configCache.glidera = defaultConfig.glidera;
|
configCache.glidera = defaultConfig.glidera;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue