combine new preferences with stored preferences
This commit is contained in:
parent
116bea1aa5
commit
fb0dcee054
|
@ -480,7 +480,6 @@ WalletService.prototype.savePreferences = function(opts, cb) {
|
|||
}];
|
||||
|
||||
opts = _.pick(opts, _.pluck(preferences, 'name'));
|
||||
|
||||
try {
|
||||
_.each(preferences, function(preference) {
|
||||
var value = opts[preference.name];
|
||||
|
@ -495,15 +494,17 @@ WalletService.prototype.savePreferences = function(opts, cb) {
|
|||
}
|
||||
|
||||
self._runLocked(cb, function(cb) {
|
||||
var preferences = Model.Preferences.create({
|
||||
walletId: self.walletId,
|
||||
copayerId: self.copayerId,
|
||||
email: opts.email,
|
||||
language: opts.language,
|
||||
unit: opts.unit,
|
||||
});
|
||||
self.storage.storePreferences(preferences, function(err) {
|
||||
return cb(err);
|
||||
self.storage.fetchPreferences(self.walletId, self.copayerId, function(err, oldPref) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var newPref = Model.Preferences.create({
|
||||
walletId: self.walletId,
|
||||
copayerId: self.copayerId,
|
||||
});
|
||||
var preferences = Model.Preferences.fromObj(_.defaults(newPref, opts, oldPref));
|
||||
self.storage.storePreferences(preferences, function(err) {
|
||||
return cb(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -260,7 +260,7 @@ helpers.createAddresses = function(server, wallet, main, change, cb) {
|
|||
|
||||
var storage, blockchainExplorer;
|
||||
|
||||
var useMongo = true;
|
||||
var useMongo = false;
|
||||
|
||||
function initStorage(cb) {
|
||||
function getDb(cb) {
|
||||
|
@ -1186,7 +1186,7 @@ describe('Wallet service', function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
it.only('should save preferences incrementally', function(done) {
|
||||
it('should save preferences incrementally', function(done) {
|
||||
async.series([
|
||||
|
||||
function(next) {
|
||||
|
|
Loading…
Reference in New Issue