Fix error on keypress

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)
This commit is contained in:
Samuel Elliott 2018-03-09 01:48:41 +00:00
parent 3578698a86
commit b24e0ef178
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 11 additions and 6 deletions

View File

@ -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,

View File

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