|
|
@ -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); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|