unsubscribe when wallet is deleted
This commit is contained in:
parent
171665afe6
commit
2d64e61654
3 changed files with 19 additions and 7 deletions
|
|
@ -1273,10 +1273,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
go.walletHome();
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/EnableNotifications', function(event) {
|
||||
$rootScope.$on('Local/SubscribeNotifications', function(event) {
|
||||
pushNotificationsService.enableNotifications();
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/UnsubscribeNotifications', function(event, walletId) {
|
||||
pushNotificationsService.unsubscribe(walletId);
|
||||
});
|
||||
|
||||
self.debouncedUpdate = lodash.throttle(function() {
|
||||
self.updateAll({
|
||||
quiet: true
|
||||
|
|
|
|||
|
|
@ -326,6 +326,8 @@ angular.module('copayApp.services')
|
|||
if (err) $log.warn(err);
|
||||
});
|
||||
|
||||
$rootScope.$emit('Local/UnsubscribeNotifications', walletId);
|
||||
|
||||
$timeout(function() {
|
||||
root.setWalletClients();
|
||||
root.setAndStoreFocus(null, function() {
|
||||
|
|
@ -397,7 +399,7 @@ angular.module('copayApp.services')
|
|||
handleImport(function() {
|
||||
root.setAndStoreFocus(walletId, function() {
|
||||
storageService.storeProfile(root.profile, function(err) {
|
||||
$rootScope.$emit('Local/EnableNotifications');
|
||||
$rootScope.$emit('Local/SubscribeNotifications');
|
||||
return cb(err, walletId);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ angular.module('copayApp.services')
|
|||
root.enableNotifications = function() {
|
||||
storageService.getDeviceToken(function(err, token) {
|
||||
|
||||
lodash.forEach(profileService.getWallets('livenet'), function(wallets) {
|
||||
lodash.forEach(profileService.getWallets('testnet'), function(wallets) {
|
||||
var opts = {};
|
||||
opts.user = wallets.id;
|
||||
opts.type = (navigator.userAgent.match(/iPhone/i)) == "iPhone" ? "ios" : (navigator.userAgent.match(/Android/i)) == "Android" ? "android" : null;
|
||||
|
|
@ -60,7 +60,7 @@ angular.module('copayApp.services')
|
|||
|
||||
root.disableNotifications = function() {
|
||||
storageService.getDeviceToken(function(err, token) {
|
||||
root.unsubscribe(token).then(function(response) {
|
||||
root.unsubscribeAll(token).then(function(response) {
|
||||
$log.debug('Unsubscribed: ' + response.status);
|
||||
},
|
||||
function(err) {
|
||||
|
|
@ -70,11 +70,17 @@ angular.module('copayApp.services')
|
|||
}
|
||||
|
||||
root.subscribe = function(opts) {
|
||||
return $http.post('http://192.168.1.128:8000/subscribe', opts);
|
||||
return $http.post('http://192.168.1.121:8000/subscribe', opts);
|
||||
}
|
||||
|
||||
root.unsubscribe = function(token) {
|
||||
return $http.post('http://192.168.1.128:8000/unsubscribe', {
|
||||
root.unsubscribe = function(user) {
|
||||
return $http.post('http://192.168.1.121:8000/unsubscribe', {
|
||||
user: user
|
||||
});
|
||||
}
|
||||
|
||||
root.unsubscribeAll = function(token) {
|
||||
return $http.post('http://192.168.1.121:8000/unsubscribe', {
|
||||
token: token
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue