From 81a82e7a12f47e515c1c018fc67b3fc510f90494 Mon Sep 17 00:00:00 2001 From: Evorp <3vorpgaming@gmail.com> Date: Mon, 29 Jul 2024 14:10:33 -0700 Subject: [PATCH] remove redundant discordIDtoName function definition --- pages/gallery/main.vue | 19 ++++++++--------- pages/gallery/modal/author-tab.vue | 33 +++++++++++++----------------- pages/gallery/modal/main.vue | 6 +++--- pages/review/main.vue | 3 ++- 4 files changed, 28 insertions(+), 33 deletions(-) diff --git a/pages/gallery/main.vue b/pages/gallery/main.vue index bb49e2e..d475b4c 100644 --- a/pages/gallery/main.vue +++ b/pages/gallery/main.vue @@ -73,7 +73,7 @@ :sort="currentSort" :error="error" @open="newShareURL" - @openNewTab="newTabShareURL" + @openNewTab="openModalInNewTab" @share="copyShareURL" /> @@ -81,7 +81,7 @@ v-model="modalOpen" :textureID="modalTextureID" :textureObj="modalTextureObj" - :contributors="loadedContributors" + :discordIDtoName="discordIDtoName" :packToName="packToName" :ignoreList="ignoreList" @share="copyShareURL" @@ -195,7 +195,7 @@ export default { navigator.clipboard.writeText(url); this.$root.showSnackBar(this.$root.lang("gallery.share_link_copied_to_clipboard"), "success"); }, - newTabShareURL(id) { + openModalInNewTab(id) { const url = this.newShareURL(id, false); window.open(url, "_blank"); }, @@ -228,7 +228,7 @@ export default { if (this.current.search) route += `/${this.current.search.replace(/ /g, "_")}`; if (this.$route.path === route) return; // new search is the same as before - return this.$router.push(route); + this.$router.push(route); }, updateSearch() { // prevent concurrency issues @@ -281,14 +281,12 @@ export default { return Number(seconds.toFixed(2)); }, resultMessage() { - const replacePlaceholders = (msg) => - msg.replace("%COUNT%", this.textures.length).replace("%SECONDS%", this.requestTime); - - return replacePlaceholders( + const str = this.textures.length === 1 ? this.$root.lang().gallery.result_stats_singular - : this.$root.lang().gallery.result_stats_plural, - ); + : this.$root.lang().gallery.result_stats_plural; + + return str.replace("%COUNT%", this.textures.length).replace("%SECONDS%", this.requestTime); }, ignoreList() { // not loaded yet @@ -310,6 +308,7 @@ export default { // if query changed but not params if (JSON.stringify(params) === JSON.stringify(prev)) return; + // done first so any routing updates also update the version/edition this.current.version = params.version; this.current.edition = params.edition; this.current.tag = params.tag; diff --git a/pages/gallery/modal/author-tab.vue b/pages/gallery/modal/author-tab.vue index 03c25e2..4bed127 100644 --- a/pages/gallery/modal/author-tab.vue +++ b/pages/gallery/modal/author-tab.vue @@ -31,18 +31,18 @@ import moment from "moment"; export default { name: "author-tab", props: { - packToName: { - type: Object, - required: true, - }, contributions: { type: Array, required: true, }, - contributors: { + packToName: { type: Object, required: true, }, + discordIDtoName: { + type: Function, + required: true, + }, }, data() { return { @@ -71,7 +71,7 @@ export default { }, { text: this.$root.lang().gallery.modal.data.authors, - value: "contributors", + value: "authors", }, ], }; @@ -81,24 +81,19 @@ export default { if (versions.length === 1) return versions[0]; return `${versions[0]} – ${versions[versions.length - 1]}`; }, - discordIDtoName(d) { - return this.contributors[d] - ? this.contributors[d].username || this.$root.lang().gallery.error_message.user_anonymous - : this.$root.lang().gallery.error_message.user_not_found; - }, timestampToDate(t) { return moment(new Date(t)).format("ll"); }, getContributions(pack) { return this.contributions - .filter((el) => pack === el.pack) - .sort((a, b) => b.date - a.date) - .map((el) => ({ - id: el.id, - date: this.timestampToDate(el.date), - contributors: el.authors.map((el) => this.discordIDtoName(el)).join(",\n"), - })); - } + .filter((el) => pack === el.pack) + .sort((a, b) => b.date - a.date) + .map((el) => ({ + id: el.id, + date: this.timestampToDate(el.date), + authors: el.authors.map((el) => this.discordIDtoName(el)).join(",\n"), + })); + }, }, computed: { packs() { diff --git a/pages/gallery/modal/main.vue b/pages/gallery/modal/main.vue index 2fa230e..cffc527 100644 --- a/pages/gallery/modal/main.vue +++ b/pages/gallery/modal/main.vue @@ -72,7 +72,7 @@ v-if="tab === tabs.authors" :contributions="textureObj.contributions" :packToName="packToName" - :contributors="contributors" + :discordIDtoName="discordIDtoName" /> @@ -124,8 +124,8 @@ export default { type: Object, required: true, }, - contributors: { - type: Object, + discordIDtoName: { + type: Function, required: true, }, // saves on duplicate code since it's already in the gallery page diff --git a/pages/review/main.vue b/pages/review/main.vue index b285d4d..bbe0b64 100644 --- a/pages/review/main.vue +++ b/pages/review/main.vue @@ -27,7 +27,8 @@ d88 888 888 888 d88 888 8888888888 888 888 8888888888 888 Y88b d88P 888 888 "Y8888P" 888 - +
404
{{ empty }}