Merge pull request #171 from JsSucks/emote-module
Start filter and db getter
This commit is contained in:
commit
c99eedd5c8
|
@ -15,6 +15,12 @@ let emotes = null;
|
|||
const emotesEnabled = true;
|
||||
|
||||
export default class {
|
||||
static get searchCache() {
|
||||
return this._searchCache || (this._searchCache = {});
|
||||
}
|
||||
static get emoteDb() {
|
||||
return emotes;
|
||||
}
|
||||
static get React() {
|
||||
return WebpackModules.getModuleByName('React');
|
||||
}
|
||||
|
@ -119,11 +125,18 @@ export default class {
|
|||
return filtered.slice(0, 10);
|
||||
}
|
||||
|
||||
static filter(regex, limit) {
|
||||
static filter(regex, limit, start = 0) {
|
||||
const key = `${regex}:${limit}:${start}`;
|
||||
if (this.searchCache.hasOwnProperty(key)) return this.searchCache[key];
|
||||
let index = 0;
|
||||
return emotes.filter(emote => {
|
||||
let startIndex = 0;
|
||||
return this.searchCache[key] = emotes.filter(emote => {
|
||||
if (index >= limit) return false;
|
||||
if (regex.test(emote.id)) {
|
||||
if (startIndex < start) {
|
||||
startIndex++;
|
||||
return false;
|
||||
}
|
||||
index++;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue