fix emote menu

This commit is contained in:
Zack Rauen 2019-06-28 02:19:36 -04:00
parent bff88ea865
commit ec46a237b7
6 changed files with 21 additions and 14 deletions

File diff suppressed because one or more lines are too long

2
js/main.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,7 @@
// Export these two first because they add settings/panels
export {default as EmoteModule} from "./emotes";
export {default as CustomCSS} from "./customcss";
export {default as VoiceMode} from "./voicemode";
export {default as ClassNormalizer} from "./classnormalizer";
export {default as DeveloperMode} from "./developermode";
@ -9,6 +13,4 @@ export {default as ColoredText} from "./coloredtext";
export {default as VoiceDisconnect} from "./voicedisconnect";
export {default as EmoteMenu} from "./emotemenu";
export {default as EmoteAutocaps} from "./emoteautocaps";
export {default as EmoteModule} from "./emotes";
export {default as WindowPrefs} from "./windowprefs";
export {default as CustomCSS} from "./customcss";
export {default as WindowPrefs} from "./windowprefs";

View File

@ -75,6 +75,7 @@ export default new class EmoteMenu extends Builtin {
this.hideEmojiCancel = this.registerSetting(this.hideEmojisID, this.enableHideEmojis, this.disableHideEmojis);
if (this.hideEmojis) this.enableHideEmojis();
if (EmoteModule.emotesLoaded) this.updateTwitchEmotes();
this.updateFavorites();
Events.on("emotes-loaded", this.updateTwitchEmotes);
}
@ -176,7 +177,7 @@ export default new class EmoteMenu extends Builtin {
while (this.teContainerInner.firstChild) this.teContainerInner.firstChild.remove();
for (const emote in EmoteModule.getCategory("TwitchGlobal")) {
if (!EmoteModule.getCategory("TwitchGlobal").hasOwnProperty(emote)) continue;
const url = EmoteModule.getCategory("TwitchGlobal")[emote];
const url = EmoteModule.getUrl("TwitchGlobal", emote);
const emoteElement = makeEmote(emote, url, {onClick: this.insertEmote.bind(this, emote)});
this.teContainerInner.append(emoteElement);
}

View File

@ -66,12 +66,14 @@ export default new class EmoteModule extends Builtin {
get BTTV2() {return Emotes.BTTV2;}
get blacklist() {return blacklist;}
get favorites() {return this.favoriteEmotes;}
getUrl(category, name) {return EmoteURLs[category].format({id: Emotes[category][name]});}
getCategory(category) {return Emotes[category];}
getRemoteFile(category) {return Utilities.repoUrl(`data/emotes/${category.toLowerCase()}.json`);}
initialize() {
super.initialize();
window.emoteModule = this;
this.favoriteEmotes = {};
const fe = DataStore.getBDData("bdfavemotes");
if (fe !== "" && fe !== null) this.favoriteEmotes = JSON.parse(window.atob(fe));
@ -149,7 +151,7 @@ export default new class EmoteModule extends Builtin {
let emoteOverride = emoteModifier.slice(0);
if (emoteName.length < 4 || blacklist.includes(emoteName)) continue;
if (!modifiers.includes(emoteModifier) || !Settings.get(this.category, "general", "modifiers")) emoteModifier = "";
if (!modifiers.includes(emoteModifier) || !Settings.get("emotes", "general", "modifiers")) emoteModifier = "";
if (!overrides.includes(emoteOverride)) emoteOverride = "";
else emoteModifier = emoteOverride;
@ -166,13 +168,13 @@ export default new class EmoteModule extends Builtin {
if (Emotes.FrankerFaceZ[emoteName]) current = "FrankerFaceZ";
}
if (!Emotes[current][emoteName] || !Settings.get(this.category, "categories", bdEmoteSettingIDs[current])) continue;
if (!Emotes[current][emoteName] || !Settings.get("emotes", "categories", bdEmoteSettingIDs[current])) continue;
const results = nodes[n].match(new RegExp(`([\\s]|^)${Utilities.escape(emoteModifier ? emoteName + ":" + emoteModifier : emoteName)}([\\s]|$)`));
if (!results) continue;
const pre = nodes[n].substring(0, results.index + results[1].length);
const post = nodes[n].substring(results.index + results[0].length - results[2].length);
nodes[n] = pre;
const emoteComponent = DiscordModules.React.createElement(BDEmote, {name: emoteName, url: Emotes[current][emoteName], modifier: emoteModifier, isFavorite: this.isFavorite(emoteName)});
const emoteComponent = DiscordModules.React.createElement(BDEmote, {name: emoteName, url: EmoteURLs[current].format({id: Emotes[current][emoteName]}), modifier: emoteModifier, isFavorite: this.isFavorite(emoteName)});
nodes.splice(n + 1, 0, post);
nodes.splice(n + 1, 0, emoteComponent);
}
@ -229,7 +231,7 @@ export default new class EmoteModule extends Builtin {
if (hasData) data = cachedData;
}
if (!data) data = await this.downloadEmotes(category);
for (const emote in data) data[emote] = EmoteURLs[category].format({id: data[emote]});
// for (const emote in data) data[emote] = EmoteURLs[category].format({id: data[emote]});
Object.assign(Emotes[category], data);
}

View File

@ -11,6 +11,8 @@ export default class BuiltinModule {
get id() {return "None";}
async initialize() {
console.log("Initialize for " + this.name);
console.log(Settings.get(this.collection, this.category, this.id), this.collection, this.category, this.id);
if (Settings.get(this.collection, this.category, this.id)) await this.enable();
Events.on("setting-updated", (collection, category, id, enabled) => {
if (collection != this.collection || category !== this.category || id !== this.id) return;