Update PersonalPins.plugin.js

This commit is contained in:
Mirco Wittrien 2020-02-04 09:26:05 +01:00
parent 9408181400
commit f8b3310f9f
1 changed files with 63 additions and 78 deletions

View File

@ -12,7 +12,7 @@ var PersonalPins = (_ => {
getDescription () {return "Similar to normal pins. Lets you save messages as notes for yourself.";} getDescription () {return "Similar to normal pins. Lets you save messages as notes for yourself.";}
getVersion () {return "1.8.7";} getVersion () {return "1.8.^9";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -267,7 +267,7 @@ var PersonalPins = (_ => {
buttoninstance.props.searchKey = buttoninstance.props.searchKey || ""; buttoninstance.props.searchKey = buttoninstance.props.searchKey || "";
return [ return [
BDFDB.ReactUtils.createElement("div", { BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.popoutheader + BDFDB.disCN.messagespopoutheader, className: BDFDB.disCN.messagespopoutheader,
style: { style: {
paddingBottom: 0 paddingBottom: 0
}, },
@ -275,7 +275,7 @@ var PersonalPins = (_ => {
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
children: [ children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
className: BDFDB.disCNS.popouttitle + BDFDB.disCN.messagespopouttitle, className: BDFDB.disCN.messagespopouttitle,
children: this.labels.popout_note_text children: this.labels.popout_note_text
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
@ -430,84 +430,69 @@ var PersonalPins = (_ => {
}); });
return [separator, BDFDB.ReactUtils.createElement("div", { return [separator, BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.messagegroupwrapper, className: BDFDB.disCN.messagespopoutgroupwrapper,
key: message.id, key: message.id,
children: BDFDB.ReactUtils.createElement("div", { children: [
className: BDFDB.disCN.messagegroupwrapperoffsetcorrection, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MessageGroup, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MessageGroup, { className: BDFDB.disCN.messagespopoutgroupcozy,
cozyClassName: BDFDB.disCN.messagespopoutmessagegroupcozy, message: message,
messages: [message], channel: channel
channel: channel, }),
inlineAttachmentMedia: true, BDFDB.ReactUtils.createElement("div", {
inlineEmbedMedia: true, className: BDFDB.disCN.messagespopoutactionbuttons,
renderEmbeds: true, children: [
renderEmbedsSmall: true, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
compact: false, className: BDFDB.disCN.messagespopoutjumpbutton,
developerMode: false, onClick: _ => {
hasDivider: false, BDFDB.LibraryModules.SelectChannelUtils.selectChannel(channel.guild_id, channel.id, message.id);
popoutPosition: BDFDB.LibraryComponents.PopoutContainer.Positions.LEFT, },
groupOption: _ => { children: BDFDB.ReactUtils.createElement("div", {
return BDFDB.ReactUtils.createElement("div", { children: BDFDB.LanguageUtils.LanguageStrings.JUMP
className: BDFDB.disCN.messagespopoutactionbuttons, })
children: [ }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagespopoutjumpbutton, className: BDFDB.disCN.messagespopoutjumpbutton,
onClick: _ => { onClick: _ => {
BDFDB.LibraryModules.SelectChannelUtils.selectChannel(channel.guild_id, channel.id, message.id); if (message.content || message.attachments.length > 1) {
}, let text = message.content || "";
children: BDFDB.ReactUtils.createElement("div", { for (let attachment of message.attachments) if (attachment.url) text += ((text ? "\n" : "") + attachment.url);
className: BDFDB.disCN.messagespopouttext, BDFDB.LibraryRequires.electron.clipboard.write({text});
children: BDFDB.LanguageUtils.LanguageStrings.JUMP }
}) else if (message.attachments.length == 1 && message.attachments[0].url) {
}), BDFDB.LibraryRequires.request({url: message.attachments[0].url, encoding: null}, (error, response, buffer) => {
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, { if (buffer) {
className: BDFDB.disCN.messagespopoutjumpbutton, if (BDFDB.LibraryRequires.process.platform === "win32" || BDFDB.LibraryRequires.process.platform === "darwin") {
onClick: _ => { BDFDB.LibraryRequires.electron.clipboard.write({image: BDFDB.LibraryRequires.electron.nativeImage.createFromBuffer(buffer)});
if (message.content || message.attachments.length > 1) { }
let text = message.content || ""; else {
for (let attachment of message.attachments) if (attachment.url) text += ((text ? "\n" : "") + attachment.url); let file = BDFDB.LibraryRequires.path.join(BDFDB.LibraryRequires.process.env["HOME"], "personalpinstemp.png");
BDFDB.LibraryRequires.electron.clipboard.write({text}); BDFDB.LibraryRequires.fs.writeFileSync(file, buffer, {encoding: null});
BDFDB.LibraryRequires.electron.clipboard.write({image: file});
BDFDB.LibraryRequires.fs.unlinkSync(file);
}
} }
else if (message.attachments.length == 1 && message.attachments[0].url) { });
BDFDB.LibraryRequires.request({url: message.attachments[0].url, encoding: null}, (error, response, buffer) => { }
if (buffer) { },
if (BDFDB.LibraryRequires.process.platform === "win32" || BDFDB.LibraryRequires.process.platform === "darwin") { children: BDFDB.ReactUtils.createElement("div", {
BDFDB.LibraryRequires.electron.clipboard.write({image: BDFDB.LibraryRequires.electron.nativeImage.createFromBuffer(buffer)}); children: BDFDB.LanguageUtils.LanguageStrings.COPY
} })
else { }),
let file = BDFDB.LibraryRequires.path.join(BDFDB.LibraryRequires.process.env["HOME"], "personalpinstemp.png"); BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
BDFDB.LibraryRequires.fs.writeFileSync(file, buffer, {encoding: null}); look: BDFDB.LibraryComponents.Button.Looks.BLANK,
BDFDB.LibraryRequires.electron.clipboard.write({image: file}); size: BDFDB.LibraryComponents.Button.Sizes.NONE,
BDFDB.LibraryRequires.fs.unlinkSync(file); onClick: (e, instance) => {
} this.removeNoteData(note);
} BDFDB.ReactUtils.forceUpdate(buttoninstance.popout._owner.stateNode);
}); },
} children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
}, className: BDFDB.disCN.messagespopoutclosebutton,
children: BDFDB.ReactUtils.createElement("div", { name: BDFDB.LibraryComponents.SvgIcon.Names.CLOSE
className: BDFDB.disCN.messagespopouttext, })
children: BDFDB.LanguageUtils.LanguageStrings.COPY })
}) ]
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
look: BDFDB.LibraryComponents.Button.Looks.BLANK,
size: BDFDB.LibraryComponents.Button.Sizes.NONE,
onClick: (e, instance) => {
this.removeNoteData(note);
BDFDB.ReactUtils.forceUpdate(buttoninstance.popout._owner.stateNode);
},
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.messagespopoutclosebutton
})
})
]
});
},
messageOption: false,
canEdit: false,
accessoriesClassName: BDFDB.disCN.messagespopoutaccessories
}) })
}) ]
})]; })];
} }