Use a counter instead of the current time for modal IDs to avoid duplicates when multiple modals are opened at the same time

This commit is contained in:
Samuel Elliott 2018-07-18 22:17:50 +01:00
parent 821f46481e
commit 27f1eec967
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 9 additions and 6 deletions

View File

@ -11,7 +11,7 @@
import { DOM, BdUI, BdMenu, Modals, Reflection } from 'ui';
import BdCss from './styles/index.scss';
import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi } from 'modules';
import { ClientLogger as Logger, ClientIPC, Utils } from 'common';
import { ClientLogger as Logger, ClientIPC, Utils, IterableWeakCollections, IterableWeakMap, IterableWeakSet } from 'common';
import { EmoteModule } from 'builtin';
import electron from 'electron';
import path from 'path';
@ -37,6 +37,7 @@ class BetterDiscord {
EmoteModule,
Logger, ClientIPC, Utils,
IterableWeakCollections, IterableWeakMap, IterableWeakSet,
plugins: PluginManager.localContent,
themes: ThemeManager.localContent,

View File

@ -51,7 +51,7 @@ export default class KeybindSetting extends Setting {
get addEventListener() { return this.on }
get removeEventListener() { return this.removeListener }
static _setup() {
static _init() {
document.addEventListener('keydown', this.__event_handler.bind(this, 'keydown'));
document.addEventListener('keyup', this.__event_handler.bind(this, 'keyup'));
document.addEventListener('keypress', this.__event_handler.bind(this, 'keypress'));
@ -73,4 +73,4 @@ export default class KeybindSetting extends Setting {
}
KeybindSetting._setup();
KeybindSetting._init();

View File

@ -17,6 +17,8 @@ import ErrorModal from './components/bd/modals/ErrorModal.vue';
import SettingsModal from './components/bd/modals/SettingsModal.vue';
import PermissionModal from './components/bd/modals/PermissionModal.vue';
let modals = 0;
class Modal extends AsyncEventEmitter {
constructor(_modal, component) {
super();
@ -36,7 +38,7 @@ class Modal extends AsyncEventEmitter {
};
this.closing = false;
this.id = Date.now();
this.id = modals++;
this.vueInstance = undefined;
this.vue = undefined;

View File

@ -120,7 +120,7 @@ export class IterableWeakCollections {
return new Set(this.getWeakSetValues(ws));
}
static _setup() {
static _init() {
const v8 = process.binding('v8');
// Enable natives syntax
@ -158,4 +158,4 @@ export class IterableWeakCollections {
}
IterableWeakCollections._setup();
IterableWeakCollections._init();