This commit is contained in:
Mirco Wittrien 2020-05-19 20:31:07 +02:00
parent e9cdacdb29
commit 2efc058653
2 changed files with 4 additions and 10 deletions

View File

@ -172,7 +172,7 @@ var GoogleTranslateOption = (_ => {
let translated = translatedMessages[e.instance.props.message.id];
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Translate_Message") : null;
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["id", ["pin", "unpin"]]]});
children.splice(index > -1 ? index + 1: children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
children.splice(index > -1 ? index + 1: 0, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: translated ? this.labels.context_messageuntranslateoption_text : this.labels.context_messagetranslateoption_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, translated ? "untranslate-message" : "translate-message"),
hint: hint && (_ => {
@ -190,7 +190,7 @@ var GoogleTranslateOption = (_ => {
if (text) {
let translating, foundTranslation, foundInput, foundOutput;
let [children2, index2] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["id", "search-google"]]});
if (index2 > -1) children2.splice(index2 > -1 ? index2 + 1 : children2.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
if (index2 > -1) children2.splice(index2 > -1 ? index2 + 1 : 0, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_googletranslateoption_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "search-translation"),
disabled: isTranslating,
@ -348,12 +348,6 @@ var GoogleTranslateOption = (_ => {
}
}
}
return;
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: ["message", "channel"]});
if (index > -1) for (let ele of children) if (ele && ele.props && ele.props.message) {
let translation = translatedMessages[ele.props.message.id];
if (translation) ele.props.message = new BDFDB.DiscordObjects.Message(Object.assign({}, ele.props.message, {content: translation.content}));
}
}
processMessageContent (e) {

View File

@ -101,7 +101,7 @@ var PersonalPins = (_ => {
let note = this.getNoteData(e.instance.props.message, e.instance.props.channel);
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Note_Message") : null;
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["id", ["pin", "unpin"]]]});
children.splice(index > -1 ? index + 1: children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
children.splice(index > -1 ? index + 1: 0, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: note ? this.labels.context_unpinoption_text : this.labels.context_pinoption_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, note ? "unpin-note" : "pin-note"),
hint: hint && (_ => {
@ -114,7 +114,7 @@ var PersonalPins = (_ => {
this.addMessageToNotes(e.instance.props.message, e.instance.props.channel);
}
}));
if (this.isNoteOutdated(note, e.instance.props.message)) children.splice(index > -1 ? index + 1: children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
if (this.isNoteOutdated(note, e.instance.props.message)) children.splice(index > -1 ? index + 1: 0, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_updateoption_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "update-note"),
action: _ => {