From b24e0ef178621178c2d562ef729da30f1307825d Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Fri, 9 Mar 2018 01:48:41 +0000 Subject: [PATCH] Fix error on keypress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uncaught TypeError: Cannot assign to read only property 'ignoreNextKeypress' of object '[object Object]' at ../node_modules/combokeys/Combokeys/index.js.module.exports.../node_modules/combokeys/Combokeys/prototype/handleKey.js.module.exports [as handleKey] (/Users/Samuel/Documents/BetterDiscord/2018-01-19/betterdiscordapp/client/dist/betterdiscord.client.…:4703) at ../node_modules/combokeys/Combokeys/index.js.module.exports.../node_modules/combokeys/Combokeys/prototype/handleKeyEvent.js.module.exports (/Users/Samuel/Documents/BetterDiscord/2018-01-19/betterdiscordapp/client/dist/betterdiscord.client.…:4752) at HTMLDocument.r (721226c….js:25) --- client/src/modules/contentmanager.js | 11 +++++++---- common/modules/utils.js | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/client/src/modules/contentmanager.js b/client/src/modules/contentmanager.js index c35c4b89..cf2f8165 100644 --- a/client/src/modules/contentmanager.js +++ b/client/src/modules/contentmanager.js @@ -10,15 +10,16 @@ import Content from './content'; import Globals from './globals'; +import Database from './database'; import { Utils, FileUtils, ClientLogger as Logger } from 'common'; -import path from 'path'; import { Events } from 'modules'; import { SettingsSet, ErrorEvent } from 'structs'; import { Modals } from 'ui'; -import Database from './database'; +import path from 'path'; +import Combokeys from 'combokeys'; /** - * Base class for external content managing + * Base class for managing external content */ export default class { @@ -209,10 +210,12 @@ export default class { userConfig.config.setSaved(); for (let setting of userConfig.config.findSettings(() => true)) { + // This will load custom settings + // Setting the content's path on only the live config (and not the default config) ensures that custom settings will not be loaded on the default settings setting.setContentPath(contentPath); } - Utils.deepfreeze(defaultConfig); + Utils.deepfreeze(defaultConfig, object => object instanceof Combokeys); const configs = { defaultConfig, diff --git a/common/modules/utils.js b/common/modules/utils.js index d032b264..99aecfa2 100644 --- a/common/modules/utils.js +++ b/common/modules/utils.js @@ -146,12 +146,14 @@ export class Utils { return value; } - static deepfreeze(object) { + static deepfreeze(object, exclude) { + if (exclude && exclude(object)) return; + if (typeof object === 'object' && object !== null) { const properties = Object.getOwnPropertyNames(object); for (let property of properties) { - this.deepfreeze(object[property]); + this.deepfreeze(object[property], exclude); } Object.freeze(object);