diff --git a/README.md b/README.md index 6fadefa..cc07627 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ as well as making it so all of the images load faster on your player's computers # Disclaimer: This module is currently in beta testing, as such there may be bugs and missing -features. To report bugs or request features you can open an issue on the -[Public Issue Tracker](https://git.varify.ca/Foundry/image-tagger/issues) or you -can send an email to [hello@varify.ca](mailto:hello@varify.ca). +features. To report bugs or request features you can: +- open an issue on the +[primary issue tracker](https://git.varify.ca/Foundry/image-tagger/issues) +- send an email to [hello@varify.ca](mailto:hello@varify.ca) +- or, open an issue on [Github](https://github.com/Eldritch-Oliver/Foundry-Image-Tagger/issues/new) diff --git a/langs/en-ca.json b/langs/en-ca.json index e2a7b55..320de4a 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -12,15 +12,15 @@ "tags": "Tags", "select": "Select", "links": "Links", - "sort-by": "Sort By" + "sort-by": "Sort By", + "page-reset-warning":"Changing any of these will reset your page to 1." }, "apps": { "ArtBrowser": { "selected": "{current}/{required} Selected", "upload-image": "Upload Image", "no-results": "No results were found for that search", - "select-image": "Select image", - "page-reset-warning": "Changing any of these will reset your page to 1." + "select-image": "Select image" }, "ArtistBrowser": { "sort-options": { diff --git a/module/apps/ArtBrowser.mjs b/module/apps/ArtBrowser.mjs index 98d3cdb..8b5f0df 100644 --- a/module/apps/ArtBrowser.mjs +++ b/module/apps/ArtBrowser.mjs @@ -272,6 +272,7 @@ export class ArtBrowser extends HandlebarsApplicationMixin(ApplicationV2) { event.stopPropagation(); const data = (new FormDataExtended(event.currentTarget)).object; this.filters = data; + this.#page = 1; this.render({ parts: [`images`] }); }; diff --git a/module/apps/ArtistBrowser.mjs b/module/apps/ArtistBrowser.mjs index 29ffc19..52318e5 100644 --- a/module/apps/ArtistBrowser.mjs +++ b/module/apps/ArtistBrowser.mjs @@ -56,7 +56,7 @@ export class ArtistBrowser extends HandlebarsApplicationMixin(ApplicationV2) { if (this.#page == page) { return }; this.#page = page; if (this.rendered) { - await this.render({ parts: [`images`] }); + await this.render({ parts: [`list`] }); return; }; return; @@ -152,6 +152,24 @@ export class ArtistBrowser extends HandlebarsApplicationMixin(ApplicationV2) { const allArtists = Object.entries(deepClone(this.#artistDB.data)); const allImages = Object.values(this.#imagesDB.data); + /* + This collates all of the image data into the required summary data for the + display of the artists. Because this does the collation all in one iteration + it is a more performant way of collecting all of the information once the + databases get larger + */ + const summary = {}; + for (const image of allImages) { + for (const artistID of image.artists) { + summary[artistID] ??= { count: 0, tags: {} }; + summary[artistID].count++; + for (const tag of image.tags) { + summary[artistID].tags[tag] ??= { name: tag, count: 0 }; + summary[artistID].tags[tag].count++; + }; + }; + }; + const artists = []; for (const [id, artist] of allArtists) { // Check if it matches the required filters @@ -162,20 +180,8 @@ export class ArtistBrowser extends HandlebarsApplicationMixin(ApplicationV2) { // Populate ephemeral data for rendering artist.id = id; - let imageCount = 0; - let tags = {}; - - for (const image of allImages) { - if (!image.artists.includes(id)) continue; - imageCount++; - for (const tag of image.tags) { - tags[tag] ??= { name: tag, count: 0 }; - tags[tag].count++; - }; - }; - - artist.imageCount = imageCount; - artist.commonTags = Object.values(tags) + artist.imageCount = summary[id].count; + artist.commonTags = Object.values(summary[id].tags) .sort((a, b) => b.count - a.count) .slice(0, 5); @@ -200,6 +206,7 @@ export class ArtistBrowser extends HandlebarsApplicationMixin(ApplicationV2) { event.preventDefault(); event.stopPropagation(); const data = (new FormDataExtended(event.currentTarget)).object; + this.#page = 1; this.filters = data; this.render({ parts: [`list`] }); }; diff --git a/templates/ArtBrowser/sidebar.hbs b/templates/ArtBrowser/sidebar.hbs index 8abb4fa..0dad469 100644 --- a/templates/ArtBrowser/sidebar.hbs +++ b/templates/ArtBrowser/sidebar.hbs @@ -1,6 +1,6 @@

- {{localize "IT.apps.ArtBrowser.page-reset-warning"}} + {{localize "IT.common.page-reset-warning"}}


diff --git a/templates/ArtistBrowser/sidebar.hbs b/templates/ArtistBrowser/sidebar.hbs index f25d2be..cccdcff 100644 --- a/templates/ArtistBrowser/sidebar.hbs +++ b/templates/ArtistBrowser/sidebar.hbs @@ -1,4 +1,10 @@ +

+ {{localize "IT.common.page-reset-warning"}} +

+ +
+