Clone data so it's not invalidated
This commit is contained in:
parent
a208d91d4b
commit
ac40f63e1f
|
@ -8,10 +8,10 @@ const theme = require('./theme.js');
|
||||||
const sysValidate = require('./system_view_validate.js');
|
const sysValidate = require('./system_view_validate.js');
|
||||||
const UserProps = require('./user_property.js');
|
const UserProps = require('./user_property.js');
|
||||||
const { getISOTimestampString } = require('./database.js');
|
const { getISOTimestampString } = require('./database.js');
|
||||||
|
const EnigAssert = require('./enigma_assert');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const assert = require('assert');
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
|
||||||
|
@ -109,7 +109,10 @@ exports.getModule = class UserConfigModule extends MenuModule {
|
||||||
// Handlers
|
// Handlers
|
||||||
//
|
//
|
||||||
saveChanges: function (formData, extraArgs, cb) {
|
saveChanges: function (formData, extraArgs, cb) {
|
||||||
assert(formData.value.password === formData.value.passwordConfirm);
|
EnigAssert(formData.value.password === formData.value.passwordConfirm);
|
||||||
|
|
||||||
|
// cache a copy of |formData| as changing a theme below can invalidate it
|
||||||
|
formData = _.clone(formData);
|
||||||
|
|
||||||
const newProperties = {
|
const newProperties = {
|
||||||
[UserProps.RealName]: formData.value.realName,
|
[UserProps.RealName]: formData.value.realName,
|
||||||
|
@ -126,7 +129,7 @@ exports.getModule = class UserConfigModule extends MenuModule {
|
||||||
self.availThemeInfo[formData.value.theme].themeId,
|
self.availThemeInfo[formData.value.theme].themeId,
|
||||||
};
|
};
|
||||||
|
|
||||||
// runtime set theme
|
// Runtime set theme
|
||||||
theme.setClientTheme(self.client, newProperties.theme_id);
|
theme.setClientTheme(self.client, newProperties.theme_id);
|
||||||
|
|
||||||
// persist all changes
|
// persist all changes
|
||||||
|
|
Loading…
Reference in New Issue