Skip to content

Commit

Permalink
remove redundant discordIDtoName function definition
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Jul 29, 2024
1 parent b05cae0 commit 81a82e7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 33 deletions.
19 changes: 9 additions & 10 deletions pages/gallery/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@
:sort="currentSort"
:error="error"
@open="newShareURL"
@openNewTab="newTabShareURL"
@openNewTab="openModalInNewTab"
@share="copyShareURL"
/>

<gallery-modal
v-model="modalOpen"
:textureID="modalTextureID"
:textureObj="modalTextureObj"
:contributors="loadedContributors"
:discordIDtoName="discordIDtoName"
:packToName="packToName"
:ignoreList="ignoreList"
@share="copyShareURL"
Expand Down Expand Up @@ -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");
},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
33 changes: 14 additions & 19 deletions pages/gallery/modal/author-tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -71,7 +71,7 @@ export default {
},
{
text: this.$root.lang().gallery.modal.data.authors,
value: "contributors",
value: "authors",
},
],
};
Expand All @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions pages/gallery/modal/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
v-if="tab === tabs.authors"
:contributions="textureObj.contributions"
:packToName="packToName"
:contributors="contributors"
:discordIDtoName="discordIDtoName"
/>
</v-tab-item>
</v-tabs-items>
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pages/review/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ d88 888 888 888 d88 888
8888888888 888 888 8888888888
888 Y88b d88P 888
888 "Y8888P" 888
</pre>
</pre
>
<p v-else class="text-h2 my-2">404</p>
<p class="my-2 px-2">{{ empty }}</p>
</div>
Expand Down

0 comments on commit 81a82e7

Please sign in to comment.