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'));
|
opts = _.pick(opts, _.pluck(preferences, 'name'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_.each(preferences, function(preference) {
|
_.each(preferences, function(preference) {
|
||||||
var value = opts[preference.name];
|
var value = opts[preference.name];
|
||||||
|
@ -495,15 +494,17 @@ WalletService.prototype.savePreferences = function(opts, cb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
self._runLocked(cb, function(cb) {
|
self._runLocked(cb, function(cb) {
|
||||||
var preferences = Model.Preferences.create({
|
self.storage.fetchPreferences(self.walletId, self.copayerId, function(err, oldPref) {
|
||||||
walletId: self.walletId,
|
if (err) return cb(err);
|
||||||
copayerId: self.copayerId,
|
|
||||||
email: opts.email,
|
var newPref = Model.Preferences.create({
|
||||||
language: opts.language,
|
walletId: self.walletId,
|
||||||
unit: opts.unit,
|
copayerId: self.copayerId,
|
||||||
});
|
});
|
||||||
self.storage.storePreferences(preferences, function(err) {
|
var preferences = Model.Preferences.fromObj(_.defaults(newPref, opts, oldPref));
|
||||||
return cb(err);
|
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 storage, blockchainExplorer;
|
||||||
|
|
||||||
var useMongo = true;
|
var useMongo = false;
|
||||||
|
|
||||||
function initStorage(cb) {
|
function initStorage(cb) {
|
||||||
function getDb(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([
|
async.series([
|
||||||
|
|
||||||
function(next) {
|
function(next) {
|
||||||
|
|
Loading…
Reference in New Issue