add search cache and push vendor to window dev object

This commit is contained in:
Jiiks 2018-03-15 15:11:46 -03:00
parent ce457e4ad4
commit 7643588b00
2 changed files with 10 additions and 4 deletions

View File

@ -15,6 +15,9 @@ let emotes = null;
const emotesEnabled = true;
export default class {
static get searchCache() {
return this._searchCache || (this._searchCache = {});
}
static get emoteDb() {
return emotes;
}
@ -123,9 +126,11 @@ export default class {
}
static filter(regex, limit, start = 0) {
const key = `${regex}:${limit}:${start}`;
if (this.searchCache.hasOwnProperty(key)) return this.searchCache[key];
let index = 0;
let startIndex = 0;
return emotes.filter(emote => {
return this.searchCache[key] = emotes.filter(emote => {
if (index >= limit) return false;
if (regex.test(emote.id)) {
if (startIndex < start) {

View File

@ -10,7 +10,7 @@
import { DOM, BdUI, Modals, Reflection } from 'ui';
import BdCss from './styles/index.scss';
import { Patcher, Events, CssEditor, Globals, ExtModuleManager, PluginManager, ThemeManager, ModuleManager, WebpackModules, Settings, Database, ReactComponents, ReactAutoPatcher, DiscordApi } from 'modules';
import { Patcher, Vendor, Events, CssEditor, Globals, ExtModuleManager, PluginManager, ThemeManager, ModuleManager, WebpackModules, Settings, Database, ReactComponents, ReactAutoPatcher, DiscordApi } from 'modules';
import { ClientLogger as Logger, ClientIPC, Utils } from 'common';
import { EmoteModule } from 'builtin';
const ignoreExternal = false;
@ -20,13 +20,14 @@ class BetterDiscord {
constructor() {
window.BDDEVMODE = function () {
if (!DEV) return;
window._bd = {
if (!DEV) return null;
return window._bd = {
DOM,
BdUI,
Modals,
Reflection,
Patcher,
Vendor,
Events,
CssEditor,
Globals,