mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
fixed double showing of recursive filtered items
This commit is contained in:
@@ -213,34 +213,46 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function recursive(sub = undefined) {
|
async function recursive(sub = undefined) {
|
||||||
const curr = window.location.href.split("#")
|
const curr = window.location.href.split("#");
|
||||||
const content = document.getRootNode().innerHTML;
|
const content = document.getRootNode().innerHTML;
|
||||||
const title = document.title;
|
const title = document.title;
|
||||||
const ischecked = document.getElementById("recursive").checked;
|
const ischecked = document.getElementById("recursive").checked;
|
||||||
const folders = document.getElementsByClassName("folders")[0];
|
const folders = document.getElementsByClassName("folders")[0];
|
||||||
|
|
||||||
if (sub == undefined) {
|
if (sub == undefined) {
|
||||||
sub = subfolders;
|
sub = subfolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ischecked) {
|
if (ischecked) {
|
||||||
window.history.replaceState({ "html": content, "pageTitle": title }, "", curr[0].split("?")[0] + "?recursive#" + curr[1])
|
window.history.replaceState({ "html": content, "pageTitle": title }, "", curr[0].split("?")[0] + "?recursive#" + curr[1]);
|
||||||
if (folders != undefined) {
|
if (folders != undefined) {
|
||||||
folders.style.display = "none";
|
folders.style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const folder of sub) {
|
for (const folder of sub) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(folder.metadata);
|
const response = await fetch(folder.metadata);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
|
const existingItems = new Set(items.map(item => item.src));
|
||||||
|
|
||||||
|
for (const image of Object.values(data.images)) {
|
||||||
|
if (!existingItems.has(image.src)) {
|
||||||
|
items.push(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (data.subfolders.length > 0) {
|
if (data.subfolders.length > 0) {
|
||||||
await recursive(data.subfolders);
|
await recursive(data.subfolders);
|
||||||
}
|
}
|
||||||
items = items.concat(Object.values(data.images));
|
|
||||||
filter();
|
filter();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch folder metadata:', error);
|
console.error('Failed to fetch folder metadata:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.history.replaceState({ "html": content, "pageTitle": title }, "", curr[0].split("?")[0] + "#" + curr[1])
|
window.history.replaceState({ "html": content, "pageTitle": title }, "", curr[0].split("?")[0] + "#" + curr[1]);
|
||||||
if (folders != undefined) {
|
if (folders != undefined) {
|
||||||
folders.style.display = "";
|
folders.style.display = "";
|
||||||
}
|
}
|
||||||
@@ -325,8 +337,7 @@
|
|||||||
if (item.src.replace(item.name, "") == path) {
|
if (item.src.replace(item.name, "") == path) {
|
||||||
shown.push(item);
|
shown.push(item);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
shown.push(item);
|
shown.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user