push notification subscribe refactor

This commit is contained in:
Gabriel Bazán 2016-01-04 08:55:28 -03:00
commit 2d07cf0e55
4 changed files with 45 additions and 36 deletions

View file

@ -118,7 +118,7 @@ angular.module('copayApp.services')
root.bindProfile = function(profile, cb) {
root.profile = profile;
configService.get(function(err) {
$log.debug('Preferences read');
if (err) return cb(err);
@ -128,20 +128,19 @@ angular.module('copayApp.services')
root._setFocus(focusedWalletId, function() {
$rootScope.$emit('Local/ProfileBound');
root.isDisclaimerAccepted(function(val) {
if (!val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
}
else {
} else {
return cb();
}
});
});
});
});
};
root.loadAndBindProfile = function(cb) {
root.loadAndBindProfile = function(cb) {
storageService.getProfile(function(err, profile) {
if (err) {
$rootScope.$emit('Local/DeviceError', err);
@ -398,6 +397,7 @@ angular.module('copayApp.services')
handleImport(function() {
root.setAndStoreFocus(walletId, function() {
storageService.storeProfile(root.profile, function(err) {
$rootScope.$emit('Local/EnableNotifications', true);
return cb(err, walletId);
});
});
@ -542,16 +542,14 @@ angular.module('copayApp.services')
if (err) $log.error(err);
return cb(true);
});
}
else {
} else {
return cb();
}
});
}
else {
} else {
return cb();
}
});
});
};
root.importLegacyWallet = function(username, password, blob, cb) {

View file

@ -231,12 +231,12 @@ angular.module('copayApp.services')
storage.get('addressbook-' + network, cb);
};
root.setNotificationsOptions = function(opts, cb) {
storage.set('notifications', opts, cb);
root.setDeviceToken = function(token, cb) {
storage.set('token', token, cb);
}
root.getNotificationsOptions = function(cb) {
storage.get('notifications', cb);
root.getDeviceToken = function(cb) {
storage.get('token', cb);
}
root.removeAddressbook = function(network, cb) {