Start filter and db getter

This commit is contained in:
Jiiks 2018-03-15 14:44:41 -03:00
parent ae63213809
commit ce457e4ad4
1 changed files with 9 additions and 1 deletions

View File

@ -15,6 +15,9 @@ let emotes = null;
const emotesEnabled = true;
export default class {
static get emoteDb() {
return emotes;
}
static get React() {
return WebpackModules.getModuleByName('React');
}
@ -119,11 +122,16 @@ export default class {
return filtered.slice(0, 10);
}
static filter(regex, limit) {
static filter(regex, limit, start = 0) {
let index = 0;
let startIndex = 0;
return emotes.filter(emote => {
if (index >= limit) return false;
if (regex.test(emote.id)) {
if (startIndex < start) {
startIndex++;
return false;
}
index++;
return true;
}