From 742131c8b4d58409af34f140c314b748a7cc12e3 Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:13:59 +0100 Subject: [PATCH] Add image limit --- web/js/imageFeed.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/web/js/imageFeed.js b/web/js/imageFeed.js index fb756fb..1ebd2a5 100644 --- a/web/js/imageFeed.js +++ b/web/js/imageFeed.js @@ -367,6 +367,14 @@ Recommended: "enabled (max performance)" uness images are erroneously deduplicat }, }); + const maxImages = app.ui.settings.addSetting({ + id: "pysssss.ImageFeed.MaxImages", + name: "🐍 Image Feed Max Images", + tooltip: `Limits the number of images in the feed to a maximum, removing the oldest images as new ones are added.`, + defaultValue: 0, + type: "number", + }); + const clearButton = $el("button.pysssss-image-feed-btn.clear-btn", { textContent: "Clear", onclick: () => { @@ -399,6 +407,11 @@ Recommended: "enabled (max performance)" uness images are erroneously deduplicat function addImageToFeed(href) { const method = feedDirection.value === "newest first" ? "prepend" : "append"; + + if (maxImages.value > 0 && imageList.children.length >= maxImages.value) { + imageList.children[method === "prepend" ? imageList.children.length - 1 : 0].remove(); + } + imageList[method]( $el("div", [ $el(