Clone data so it's not invalidated

This commit is contained in:
Bryan Ashby 2023-04-25 10:24:11 -06:00
parent a208d91d4b
commit ac40f63e1f
1 changed files with 6 additions and 3 deletions

View File

@ -8,10 +8,10 @@ const theme = require('./theme.js');
const sysValidate = require('./system_view_validate.js');
const UserProps = require('./user_property.js');
const { getISOTimestampString } = require('./database.js');
const EnigAssert = require('./enigma_assert');
// deps
const async = require('async');
const assert = require('assert');
const _ = require('lodash');
const moment = require('moment');
@ -109,7 +109,10 @@ exports.getModule = class UserConfigModule extends MenuModule {
// Handlers
//
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 = {
[UserProps.RealName]: formData.value.realName,
@ -126,7 +129,7 @@ exports.getModule = class UserConfigModule extends MenuModule {
self.availThemeInfo[formData.value.theme].themeId,
};
// runtime set theme
// Runtime set theme
theme.setClientTheme(self.client, newProperties.theme_id);
// persist all changes