stuff
This commit is contained in:
parent
cab234aa2e
commit
fda66804eb
|
@ -69,7 +69,8 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
} : (([Plugin, BDFDB]) => {
|
} : (([Plugin, BDFDB]) => {
|
||||||
const imgUrlReplaceString = "DEVILBRO_BD_REVERSEIMAGESEARCH_REPLACE_IMAGEURL";
|
const imgUrlReplaceString = "DEVILBRO_BD_REVERSEIMAGESEARCH_REPLACE_IMAGEURL";
|
||||||
var firedEvents = [], clickedImage;
|
var firedEvents = [], clickedImage, loadedImages = [], searching = false;
|
||||||
|
|
||||||
var settings = {}, amounts = {}, zoomSettings = {}, engines = {}, enabledEngines = {}, ownLocations = {}, downloadsFolder;
|
var settings = {}, amounts = {}, zoomSettings = {}, engines = {}, enabledEngines = {}, ownLocations = {}, downloadsFolder;
|
||||||
|
|
||||||
const ImageDetails = class ImageDetails extends BdApi.React.Component {
|
const ImageDetails = class ImageDetails extends BdApi.React.Component {
|
||||||
|
@ -358,6 +359,7 @@ module.exports = (_ => {
|
||||||
title: "Your own Download Locations:",
|
title: "Your own Download Locations:",
|
||||||
dividerTop: true,
|
dividerTop: true,
|
||||||
children: Object.keys(ownLocations).map(name => {
|
children: Object.keys(ownLocations).map(name => {
|
||||||
|
let locationName = name;
|
||||||
let editable = name != "Downloads";
|
let editable = name != "Downloads";
|
||||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Card, {
|
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Card, {
|
||||||
horizontal: true,
|
horizontal: true,
|
||||||
|
@ -366,39 +368,40 @@ module.exports = (_ => {
|
||||||
grow: 0,
|
grow: 0,
|
||||||
basis: "180px",
|
basis: "180px",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
value: name,
|
value: locationName,
|
||||||
placeholder: name,
|
placeholder: locationName,
|
||||||
size: BDFDB.LibraryComponents.TextInput.Sizes.MINI,
|
size: BDFDB.LibraryComponents.TextInput.Sizes.MINI,
|
||||||
maxLength: 100000000000000000000,
|
maxLength: 100000000000000000000,
|
||||||
style: {marginRight: 6},
|
style: {marginRight: 6},
|
||||||
disabled: !editable,
|
disabled: !editable,
|
||||||
onChange: !editable ? null : value => {
|
onChange: !editable ? null : value => {
|
||||||
ownLocations[value] = ownLocations[name];
|
ownLocations[value] = ownLocations[locationName];
|
||||||
delete ownLocations[name];
|
delete ownLocations[locationName];
|
||||||
|
locationName = value;
|
||||||
BDFDB.DataUtils.save(ownLocations, this, "ownLocations");
|
BDFDB.DataUtils.save(ownLocations, this, "ownLocations");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
value: ownLocations[name].location,
|
value: ownLocations[locationName].location,
|
||||||
placeholder: ownLocations[name].location,
|
placeholder: ownLocations[locationName].location,
|
||||||
size: BDFDB.LibraryComponents.TextInput.Sizes.MINI,
|
size: BDFDB.LibraryComponents.TextInput.Sizes.MINI,
|
||||||
maxLength: 100000000000000000000,
|
maxLength: 100000000000000000000,
|
||||||
style: {marginRight: 10},
|
style: {marginRight: 10},
|
||||||
disabled: !editable,
|
disabled: !editable,
|
||||||
onChange: !editable ? null : value => {
|
onChange: !editable ? null : value => {
|
||||||
ownLocations[name].location = value;
|
ownLocations[locationName].location = value;
|
||||||
BDFDB.DataUtils.save(ownLocations, this, "ownLocations");
|
BDFDB.DataUtils.save(ownLocations, this, "ownLocations");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
|
||||||
value: ownLocations[name].enabled,
|
value: ownLocations[locationName].enabled,
|
||||||
size: BDFDB.LibraryComponents.Switch.Sizes.MINI,
|
size: BDFDB.LibraryComponents.Switch.Sizes.MINI,
|
||||||
onChange: value => {
|
onChange: value => {
|
||||||
ownLocations[name].enabled = value;
|
ownLocations[locationName].enabled = value;
|
||||||
BDFDB.DataUtils.save(ownLocations, this, "ownLocations");
|
BDFDB.DataUtils.save(ownLocations, this, "ownLocations");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -406,7 +409,7 @@ module.exports = (_ => {
|
||||||
],
|
],
|
||||||
noRemove: !editable,
|
noRemove: !editable,
|
||||||
onRemove: !editable ? null : _ => {
|
onRemove: !editable ? null : _ => {
|
||||||
delete ownLocations[name];
|
delete ownLocations[locationName];
|
||||||
BDFDB.DataUtils.save(ownLocations, this, "ownLocations");
|
BDFDB.DataUtils.save(ownLocations, this, "ownLocations");
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel);
|
||||||
}
|
}
|
||||||
|
@ -637,13 +640,37 @@ module.exports = (_ => {
|
||||||
if (clickedImage) e.instance.props.cachedImage = clickedImage;
|
if (clickedImage) e.instance.props.cachedImage = clickedImage;
|
||||||
let url = e.instance.props.cachedImage && e.instance.props.cachedImage.src ? e.instance.props.cachedImage : e.instance.props.src;
|
let url = e.instance.props.cachedImage && e.instance.props.cachedImage.src ? e.instance.props.cachedImage : e.instance.props.src;
|
||||||
url = url.src || url;
|
url = url.src || url;
|
||||||
let messages = this.getMessageGroupOfImage(url);
|
|
||||||
if (e.returnvalue) {
|
if (e.returnvalue) {
|
||||||
|
let message = !searching && BDFDB.ReactUtils.findValue(e.instance.props.cachedImage, "message", {up: true});
|
||||||
|
if (message) {
|
||||||
|
searching = true;
|
||||||
|
BDFDB.LibraryModules.APIUtils.get({
|
||||||
|
url: BDFDB.DiscordConstants.Endpoints.SEARCH_CHANNEL(message.channel_id),
|
||||||
|
oldFormErrors: true,
|
||||||
|
query: this.createQuery(message, true)
|
||||||
|
}).then(result => {
|
||||||
|
BDFDB.LibraryModules.APIUtils.get({
|
||||||
|
url: BDFDB.DiscordConstants.Endpoints.SEARCH_CHANNEL(message.channel_id),
|
||||||
|
oldFormErrors: true,
|
||||||
|
query: this.createQuery(message, false)
|
||||||
|
}).then(result2 => {
|
||||||
|
searching = false;
|
||||||
|
let found = [], messages = BDFDB.ArrayUtils.keySort([
|
||||||
|
message,
|
||||||
|
[].concat(result.body.messages).reverse(),
|
||||||
|
[].concat(result2.body.messages)
|
||||||
|
].flat(10).filter(m => {
|
||||||
|
if (!found.includes(m.id) && m.attachments.length || m.embeds.filter(embed => embed.type == "image").length) {
|
||||||
|
found.push(m.id);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}), "id");
|
||||||
|
console.log(messages);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.downloadlink]]});
|
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.downloadlink]]});
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
children[index].props.onClick = event => {
|
|
||||||
return event.shiftKey;
|
|
||||||
};
|
|
||||||
let openContext = event => {
|
let openContext = event => {
|
||||||
BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
||||||
children: Object.keys(zoomSettings).map(type => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuSliderItem, Object.assign({
|
children: Object.keys(zoomSettings).map(type => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuSliderItem, Object.assign({
|
||||||
|
@ -726,8 +753,8 @@ module.exports = (_ => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let imageIndex = 0, amount = 1;
|
let imageIndex = 0, amount = 1;
|
||||||
if (messages.length) {
|
if (loadedImages.length) {
|
||||||
let data = this.getSiblingsAndPosition(url, messages);
|
let data = this.getSiblingsAndPosition(url);
|
||||||
imageIndex = data.index;
|
imageIndex = data.index;
|
||||||
amount = data.amount;
|
amount = data.amount;
|
||||||
if (data.previous) {
|
if (data.previous) {
|
||||||
|
@ -760,9 +787,9 @@ module.exports = (_ => {
|
||||||
if (e.node) {
|
if (e.node) {
|
||||||
let modal = BDFDB.DOMUtils.getParent(BDFDB.dotCNC.modal + BDFDB.dotCN.layermodal, e.node);
|
let modal = BDFDB.DOMUtils.getParent(BDFDB.dotCNC.modal + BDFDB.dotCN.layermodal, e.node);
|
||||||
if (modal) {
|
if (modal) {
|
||||||
modal.className = BDFDB.DOMUtils.formatClassName(modal.className, messages.length && BDFDB.disCN._imageutilitiesgallery, settings.addDetails && BDFDB.disCN._imageutilitiesdetailsadded);
|
modal.className = BDFDB.DOMUtils.formatClassName(modal.className, loadedImages.length && BDFDB.disCN._imageutilitiesgallery, settings.addDetails && BDFDB.disCN._imageutilitiesdetailsadded);
|
||||||
this.cleanupListeners("Gallery");
|
this.cleanupListeners("Gallery");
|
||||||
if (messages.length) {
|
if (loadedImages.length) {
|
||||||
document.keydownImageUtilitiesGalleryListener = event => {
|
document.keydownImageUtilitiesGalleryListener = event => {
|
||||||
if (!document.contains(e.node)) this.cleanupListeners("Gallery");
|
if (!document.contains(e.node)) this.cleanupListeners("Gallery");
|
||||||
else if (!firedEvents.includes("Gallery")) {
|
else if (!firedEvents.includes("Gallery")) {
|
||||||
|
@ -905,7 +932,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (settings.resizeImage && e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.imagemodalimage) > -1 && BDFDB.ReactUtils.findOwner(BDFDB.ObjectUtils.get(e, `instance.${BDFDB.ReactUtils.instanceKey}`), {name: "ImageModal", up: true})) {
|
if (settings.resizeImage && e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.imagemodalimage) > -1 && BDFDB.ReactUtils.findOwner(BDFDB.ObjectUtils.get(e, `instance.${BDFDB.ReactUtils.instanceKey}`), {name: "ImageModal", up: true})) {
|
||||||
let data = settings.enableGallery ? this.getSiblingsAndPosition(e.instance.props.src, this.getMessageGroupOfImage(e.instance.props.src)) : {};
|
let data = settings.enableGallery ? this.getSiblingsAndPosition(e.instance.props.src) : {};
|
||||||
let aRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCN.appmount));
|
let aRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCN.appmount));
|
||||||
let ratio = Math.min((aRects.width * (data.previous || data.next ? 0.8 : 1) - 20) / e.instance.props.width, (aRects.height - (settings.addDetails ? 310 : 100)) / e.instance.props.height);
|
let ratio = Math.min((aRects.width * (data.previous || data.next ? 0.8 : 1) - 20) / e.instance.props.width, (aRects.height - (settings.addDetails ? 310 : 100)) / e.instance.props.height);
|
||||||
let width = Math.round(ratio * e.instance.props.width);
|
let width = Math.round(ratio * e.instance.props.width);
|
||||||
|
@ -941,6 +968,16 @@ module.exports = (_ => {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createQuery (message, before) {
|
||||||
|
return BDFDB.LibraryModules.APIEncodeUtils.stringify(BDFDB.ObjectUtils.filter({
|
||||||
|
has: ["image", "embed"],
|
||||||
|
include_nsfw: true,
|
||||||
|
min_id: !before && message.id,
|
||||||
|
max_id: before && message.id,
|
||||||
|
sort_order: before ? "desc" : "asc"
|
||||||
|
}, n => n));
|
||||||
|
}
|
||||||
|
|
||||||
isValidImg (url) {
|
isValidImg (url) {
|
||||||
const file = url && (BDFDB.LibraryModules.URLParser.parse(url).pathname || "").toLowerCase();
|
const file = url && (BDFDB.LibraryModules.URLParser.parse(url).pathname || "").toLowerCase();
|
||||||
return file && (url.startsWith("https://images-ext-2.discordapp.net/") || file.endsWith(".jpg") || file.endsWith(".jpeg") || file.endsWith(".png") || file.endsWith(".gif") || file.endsWith(".apng") || file.endsWith(".webp") || file.endsWith(".svg"));
|
return file && (url.startsWith("https://images-ext-2.discordapp.net/") || file.endsWith(".jpg") || file.endsWith(".jpeg") || file.endsWith(".png") || file.endsWith(".gif") || file.endsWith(".apng") || file.endsWith(".webp") || file.endsWith(".svg"));
|
||||||
|
@ -1013,6 +1050,9 @@ module.exports = (_ => {
|
||||||
else return wholePath;
|
else return wholePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getImages (src, instance) {
|
||||||
|
}
|
||||||
|
|
||||||
getMessageGroupOfImage (src) {
|
getMessageGroupOfImage (src) {
|
||||||
if (src && settings.enableGallery) for (let message of document.querySelectorAll(BDFDB.dotCN.message)) for (let img of message.querySelectorAll(BDFDB.dotCNS.imagewrapper + "img")) if (this.isSameImage(src, img)) {
|
if (src && settings.enableGallery) for (let message of document.querySelectorAll(BDFDB.dotCN.message)) for (let img of message.querySelectorAll(BDFDB.dotCNS.imagewrapper + "img")) if (this.isSameImage(src, img)) {
|
||||||
let previousSiblings = [], nextSiblings = [];
|
let previousSiblings = [], nextSiblings = [];
|
||||||
|
@ -1034,8 +1074,8 @@ module.exports = (_ => {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
getSiblingsAndPosition (url, messages) {
|
getSiblingsAndPosition (url) {
|
||||||
let images = messages.map(n => Array.from(n.querySelectorAll(BDFDB.dotCNS.imagewrapper + "img"))).flat().filter(img => !BDFDB.DOMUtils.getParent(BDFDB.dotCN.spoilerhidden, img));
|
let images = loadedImages.map(n => Array.from(n.querySelectorAll(BDFDB.dotCNS.imagewrapper + "img"))).flat().filter(img => !BDFDB.DOMUtils.getParent(BDFDB.dotCN.spoilerhidden, img));
|
||||||
let next, previous, index = 0, amount = images.length;
|
let next, previous, index = 0, amount = images.length;
|
||||||
for (let i = 0; i < amount; i++) if (this.isSameImage(url, images[i])) {
|
for (let i = 0; i < amount; i++) if (this.isSameImage(url, images[i])) {
|
||||||
index = i;
|
index = i;
|
||||||
|
|
|
@ -14,8 +14,13 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "ServerFolders",
|
"name": "ServerFolders",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "6.8.5",
|
"version": "6.8.6",
|
||||||
"description": "Patch Discords native Folders in a way to open Servers within a Folder in a new bar to the right, also adds a bunch of new features to more easily organize, customize and manage your Folders"
|
"description": "Patch Discords native Folders in a way to open Servers within a Folder in a new bar to the right, also adds a bunch of new features to more easily organize, customize and manage your Folders"
|
||||||
|
},
|
||||||
|
"changeLog": {
|
||||||
|
"fixed": {
|
||||||
|
"Custom Icons": "You can now add custom icons again"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -353,7 +358,7 @@ module.exports = (_ => {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||||
children: BDFDB.LanguageUtils.LanguageStrings.ADD,
|
children: BDFDB.LanguageUtils.LanguageStrings.ADD,
|
||||||
onClick: (e, instance) => {
|
onClick: (e, instance) => {
|
||||||
let inputIns = BDFDB.ReactUtils.findOwner(this, {name: "BDFDBInput", all: true, unlimited: true});
|
let inputIns = BDFDB.ReactUtils.findOwner(this, {name: "BDFDB_TextInput", all: true, unlimited: true});
|
||||||
if (inputIns.length == 2 && inputIns[0].props.value && inputIns[1].props.value) {
|
if (inputIns.length == 2 && inputIns[0].props.value && inputIns[1].props.value) {
|
||||||
this.checkImage(inputIns[0].props.value, openIcon => {
|
this.checkImage(inputIns[0].props.value, openIcon => {
|
||||||
this.checkImage(inputIns[1].props.value, closedIcon => {
|
this.checkImage(inputIns[1].props.value, closedIcon => {
|
||||||
|
@ -362,11 +367,11 @@ module.exports = (_ => {
|
||||||
this.props.open = null;
|
this.props.open = null;
|
||||||
this.props.closed = null;
|
this.props.closed = null;
|
||||||
BDFDB.PatchUtils.forceAllUpdates(_this, "GuildFolderSettingsModal");
|
BDFDB.PatchUtils.forceAllUpdates(_this, "GuildFolderSettingsModal");
|
||||||
BDFDB.NotificationUtils.toast("Custom Icon was added to selection", {type: "success"});
|
BDFDB.NotificationUtils.toast("Custom Icon was added to Selection", {type: "success"});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else BDFDB.NotificationUtils.toast("Add an image for the open and the closed icon", {type: "danger"});
|
else BDFDB.NotificationUtils.toast("Add an Image for the open and closed Icon", {type: "danger"});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
@ -1821,7 +1826,7 @@ module.exports = (_ => {
|
||||||
modal_colorpicker2: "Secondary Folder Color",
|
modal_colorpicker2: "Secondary Folder Color",
|
||||||
modal_colorpicker3: "Tooltip Color",
|
modal_colorpicker3: "Tooltip Color",
|
||||||
modal_colorpicker4: "Font Color",
|
modal_colorpicker4: "Font Color",
|
||||||
modal_copytooltipcolor: "Use the same Color for all servers in a Folder",
|
modal_copytooltipcolor: "Use the same Color for all Servers in a Folder",
|
||||||
modal_customclosed: "Closed icon",
|
modal_customclosed: "Closed icon",
|
||||||
modal_customopen: "Open icon",
|
modal_customopen: "Open icon",
|
||||||
modal_custompreview: "Icon preview",
|
modal_custompreview: "Icon preview",
|
||||||
|
|
Loading…
Reference in New Issue