2020-07-16 07:42:56 +02:00
|
|
|
import Builtin from "../../structs/builtin";
|
2020-07-24 10:59:16 +02:00
|
|
|
import {Utilities, WebpackModules, React} from "modules";
|
|
|
|
import Tabs from "./tabs";
|
2020-07-25 10:22:57 +02:00
|
|
|
|
2020-07-24 10:59:16 +02:00
|
|
|
const EmojiPicker = WebpackModules.find(m => m.type && m.type.displayName == "ExpressionPicker");
|
2019-05-31 07:53:11 +02:00
|
|
|
export default new class EmoteMenu extends Builtin {
|
|
|
|
get name() {return "EmoteMenu";}
|
2019-06-06 06:28:43 +02:00
|
|
|
get collection() {return "emotes";}
|
|
|
|
get category() {return "general";}
|
|
|
|
get id() {return "emoteMenu";}
|
|
|
|
get hideEmojisID() {return "hideEmojiMenu";}
|
2019-06-06 21:57:25 +02:00
|
|
|
get hideEmojis() {return this.get(this.hideEmojisID);}
|
2019-05-31 07:53:11 +02:00
|
|
|
|
2020-07-24 10:59:16 +02:00
|
|
|
enabled() {
|
2020-07-25 10:22:57 +02:00
|
|
|
this.before(EmojiPicker, "type", (_, [props]) => {
|
|
|
|
if (props.expressionPickerView == "emoji" && this.hideEmojis) props.expressionPickerView = "gif";
|
2020-07-24 10:59:16 +02:00
|
|
|
});
|
2020-07-25 10:22:57 +02:00
|
|
|
this.after(EmojiPicker, "type", (_, [props], returnValue) => {
|
|
|
|
const head = Utilities.getNestedProp(returnValue, "props.children.props.children.1.props.children.0.props.children.props.children");
|
|
|
|
const body = Utilities.getNestedProp(returnValue, "props.children.props.children.1.props.children");
|
|
|
|
if (!head || !body) return returnValue;
|
|
|
|
|
|
|
|
const selected = props.expressionPickerView;
|
2020-07-24 11:12:48 +02:00
|
|
|
const currentTab = Tabs.find(e => e.id === selected);
|
2020-07-25 10:22:57 +02:00
|
|
|
const tabProps = head[0].props;
|
|
|
|
head.push(
|
2020-07-24 10:59:16 +02:00
|
|
|
...Tabs.map(e => React.createElement("div", {
|
2020-07-25 10:22:57 +02:00
|
|
|
"id": e.id + "-tab",
|
|
|
|
"role": "tab",
|
2020-07-24 10:59:16 +02:00
|
|
|
"aria-selected": selected == e.id,
|
2020-07-25 10:22:57 +02:00
|
|
|
"className": tabProps.className,
|
2020-07-24 10:59:16 +02:00
|
|
|
}, React.createElement(tabProps.children.type, {
|
|
|
|
viewType: e.id,
|
|
|
|
isActive: selected == e.id,
|
|
|
|
setActiveView: tabProps.children.props.setActiveView
|
|
|
|
}, e.label))
|
|
|
|
));
|
2020-07-25 10:22:57 +02:00
|
|
|
if (currentTab) body[2] = currentTab.element();
|
|
|
|
if (this.hideEmojis) head.splice(head.findIndex(e=>e.props.id == "emoji-picker-tab"), 1);
|
|
|
|
});
|
|
|
|
}
|
2019-05-31 07:53:11 +02:00
|
|
|
|
|
|
|
disabled() {
|
2020-07-24 10:59:16 +02:00
|
|
|
this.unpatchAll();
|
2019-05-31 07:53:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|