stuff
This commit is contained in:
parent
efe0a541ad
commit
a248a23501
|
@ -2,7 +2,7 @@
|
||||||
* @name ImageUtilities
|
* @name ImageUtilities
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 5.4.2
|
* @version 5.4.3
|
||||||
* @description Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.)
|
* @description Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.)
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -137,14 +137,20 @@ module.exports = (_ => {
|
||||||
const ImageDetailsComponent = class ImageDetails extends BdApi.React.Component {
|
const ImageDetailsComponent = class ImageDetails extends BdApi.React.Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
BDFDB.DOMUtils.addClass(BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagemosaiconebyonegridsingle, BDFDB.ReactUtils.findDOMNode(this)), BDFDB.disCN._imageutilitiesimagedetailsadded);
|
BDFDB.DOMUtils.addClass(BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagemosaiconebyonegridsingle, BDFDB.ReactUtils.findDOMNode(this)), BDFDB.disCN._imageutilitiesimagedetailsadded);
|
||||||
this.props.attachment = BDFDB.ReactUtils.findValue(BDFDB.ObjectUtils.get(this, `${BDFDB.ReactUtils.instanceKey}.return`), "attachment", {up: true});
|
let item = BDFDB.ReactUtils.findValue(BDFDB.ObjectUtils.get(this, `${BDFDB.ReactUtils.instanceKey}.return`), "item", {up: true});
|
||||||
BDFDB.ReactUtils.forceUpdate(this);
|
if (item && item.originalItem) {
|
||||||
|
this.props.attachment = item.originalItem;
|
||||||
|
BDFDB.ReactUtils.forceUpdate(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
if ((!this.props.attachment || !this.props.attachment.size) && !this.props.loaded) {
|
if ((!this.props.attachment || !this.props.attachment.size) && !this.props.loaded) {
|
||||||
this.props.loaded = true;
|
this.props.loaded = true;
|
||||||
this.props.attachment = BDFDB.ReactUtils.findValue(BDFDB.ObjectUtils.get(this, `${BDFDB.ReactUtils.instanceKey}.return`), "attachment", {up: true});
|
let item = BDFDB.ReactUtils.findValue(BDFDB.ObjectUtils.get(this, `${BDFDB.ReactUtils.instanceKey}.return`), "item", {up: true});
|
||||||
BDFDB.ReactUtils.forceUpdate(this);
|
if (item && item.originalItem) {
|
||||||
|
this.props.attachment = item.originalItem;
|
||||||
|
BDFDB.ReactUtils.forceUpdate(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
@ -1393,14 +1399,14 @@ module.exports = (_ => {
|
||||||
processLazyImageZoomable (e) {
|
processLazyImageZoomable (e) {
|
||||||
if (!e.instance.props.original || e.instance.props.src.indexOf("https://media.discordapp.net/attachments") != 0) return;
|
if (!e.instance.props.original || e.instance.props.src.indexOf("https://media.discordapp.net/attachments") != 0) return;
|
||||||
if (this.settings.detailsSettings.tooltip || this.settings.detailsSettings.footnote && e.instance.props.mediaLayoutType == "MOSAIC" && (BDFDB.ReactUtils.findValue(BDFDB.ObjectUtils.get(e, `instance.${BDFDB.ReactUtils.instanceKey}`), "message", {up: true}) || {attachments: []}).attachments.filter(n => n.content_type && n.content_type.startsWith("image")).length > 1) {
|
if (this.settings.detailsSettings.tooltip || this.settings.detailsSettings.footnote && e.instance.props.mediaLayoutType == "MOSAIC" && (BDFDB.ReactUtils.findValue(BDFDB.ObjectUtils.get(e, `instance.${BDFDB.ReactUtils.instanceKey}`), "message", {up: true}) || {attachments: []}).attachments.filter(n => n.content_type && n.content_type.startsWith("image")).length > 1) {
|
||||||
const attachment = BDFDB.ReactUtils.findValue(e.instance, "attachment", {up: true});
|
const item = BDFDB.ReactUtils.findValue(e.instance, "item", {up: true});
|
||||||
if (attachment) {
|
if (item && item.originalItem) {
|
||||||
const onMouseEnter = e.returnvalue.props.onMouseEnter;
|
const onMouseEnter = e.returnvalue.props.onMouseEnter;
|
||||||
e.returnvalue.props.onMouseEnter = BDFDB.TimeUtils.suppress((...args) => {
|
e.returnvalue.props.onMouseEnter = BDFDB.TimeUtils.suppress((...args) => {
|
||||||
BDFDB.TooltipUtils.create(args[0].target, [
|
BDFDB.TooltipUtils.create(args[0].target, [
|
||||||
attachment.filename,
|
item.originalItem.filename,
|
||||||
BDFDB.NumberUtils.formatBytes(attachment.size),
|
BDFDB.NumberUtils.formatBytes(item.originalItem.size),
|
||||||
`${attachment.width}x${attachment.height}px`
|
`${item.originalItem.width}x${item.originalItem.height}px`
|
||||||
].map(l => BDFDB.ReactUtils.createElement("div", {style: {padding: "2px 0"}, children: l})), {
|
].map(l => BDFDB.ReactUtils.createElement("div", {style: {padding: "2px 0"}, children: l})), {
|
||||||
type: "right",
|
type: "right",
|
||||||
delay: this.settings.detailsSettings.tooltipDelay
|
delay: this.settings.detailsSettings.tooltipDelay
|
||||||
|
@ -1441,14 +1447,14 @@ module.exports = (_ => {
|
||||||
if (this.settings.rescaleSettings.messages != "NONE" && !e.instance.props.inline && e.instance.props.type == "attachment" && e.instance.props.containerStyles) e.instance.props.containerStyles.maxWidth = "100%";
|
if (this.settings.rescaleSettings.messages != "NONE" && !e.instance.props.inline && e.instance.props.type == "attachment" && e.instance.props.containerStyles) e.instance.props.containerStyles.maxWidth = "100%";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (e.instance.state && e.instance.state.visible) return;
|
||||||
if (this.settings.general.nsfwMode && typeof e.returnvalue.props.children == "function") {
|
if (this.settings.general.nsfwMode && typeof e.returnvalue.props.children == "function") {
|
||||||
let childrenRender = e.returnvalue.props.children;
|
let childrenRender = e.returnvalue.props.children;
|
||||||
e.returnvalue.props.children = BDFDB.TimeUtils.suppress((...args) => {
|
e.returnvalue.props.children = BDFDB.TimeUtils.suppress((...args) => {
|
||||||
let returnedChildren = childrenRender(...args);
|
let returnedChildren = childrenRender(...args);
|
||||||
let attachment = BDFDB.ReactUtils.findValue(returnedChildren, "attachment");
|
let item = BDFDB.ReactUtils.findValue(returnedChildren, "item");
|
||||||
if (attachment && attachment.nsfw) {
|
if (item && item.originalItem && item.originalItem.nsfw) {
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(returnedChildren, {name: "SpoilerWarning"});
|
returnedChildren.props.children[0] = BDFDB.ReactUtils.createElement("div", {
|
||||||
if (index > -1) children[index] = BDFDB.ReactUtils.createElement("div", {
|
|
||||||
className: BDFDB.disCN.spoilerwarning,
|
className: BDFDB.disCN.spoilerwarning,
|
||||||
children: "NSFW"
|
children: "NSFW"
|
||||||
});
|
});
|
||||||
|
|
|
@ -625,7 +625,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
isNoteOutdated (note, message) {
|
isNoteOutdated (note, message) {
|
||||||
let noteMessage = note && JSON.parse(note.message), keys = ["content", "embeds", "attachment"];
|
let noteMessage = note && JSON.parse(note.message), keys = ["content", "embeds", "attachment", "item"];
|
||||||
return noteMessage && !BDFDB.equals(BDFDB.ObjectUtils.extract(noteMessage, keys), BDFDB.ObjectUtils.extract(message, keys));
|
return noteMessage && !BDFDB.equals(BDFDB.ObjectUtils.extract(noteMessage, keys), BDFDB.ObjectUtils.extract(message, keys));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue