[Posts] Fix Quick/Recent tags not showing

Result of my inability to make changes everywhere I need to.
c9a084e0a3
Also remove artistTags which seems to have never been used.
This commit is contained in:
Earlopain 2023-08-30 20:39:58 +02:00
parent 40db4d6136
commit 6529f69628
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
4 changed files with 18 additions and 12 deletions

View File

@ -35,7 +35,7 @@
import Utility from "./utility.js";
function tagSorter(a, b) {
return a[0] > b[0] ? 1 : -1;
return a.name > b.name ? 1 : -1;
}
export default {

View File

@ -14,7 +14,7 @@
<script>
function tagSorter(a, b) {
return a[0] > b[0] ? 1 : -1;
return a.name > b.name ? 1 : -1;
}
export default {
props: ['tags', 'related', 'loading'],
@ -22,7 +22,6 @@
return {
uploaded: (window.uploaderSettings.uploadTags || []),
recent: (window.uploaderSettings.recentTags || []).sort(tagSorter),
artists: (window.uploaderSettings.artistTags || []).sort(tagSorter)
};
},
methods: {
@ -67,12 +66,6 @@
tags: this.recent
});
}
if (this.artists && this.artists.length) {
groups.push({
title: "Artists",
tags: this.artists
});
}
if (this.related && this.related.length) {
for (let i = 0; i < this.related.length; i++) {
groups.push(this.related[i]);

View File

@ -283,7 +283,7 @@
{name: 'Taur'}];
function tagSorter(a, b) {
return a[0] > b[0] ? 1 : -1;
return a.name > b.name ? 1 : -1;
}
function unloadWarning() {

View File

@ -166,7 +166,14 @@ class UserPresenter
tag_names = user&.favorite_tags.to_s.split
tag_names = TagAlias.to_aliased(tag_names)
indices = tag_names.each_with_index.map {|x, i| [x, i]}.to_h
Tag.where(name: tag_names).map {|x| [x.name, x.post_count, x.category]}.sort_by {|x| indices[x[0]] }
tags = Tag.where(name: tag_names).map do |tag|
{
name: tag.name,
count: tag.post_count,
category_id: tag.category,
}
end
tags.sort_by { |entry| indices[entry[:name]] }
end
def recent_tags_with_types
@ -174,6 +181,12 @@ class UserPresenter
tags = versions.flat_map(&:added_tags)
tags = tags.group_by(&:itself).transform_values(&:size).sort_by { |tag, count| [-count, tag] }.map(&:first)
tags = tags.take(50)
Tag.where(name: tags).map {|x| [x.name, x.post_count, x.category]}
Tag.where(name: tags).map do |tag|
{
name: tag.name,
count: tag.post_count,
category_id: tag.category,
}
end
end
end