mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
fix bad getTags code
This commit is contained in:
+25
-7
@@ -224,18 +224,36 @@ func fetchUserWorks(r *http.Request, user *User, id string, category UserWorkCat
|
||||
|
||||
// Fetch frequent tags if requested
|
||||
if getTags {
|
||||
var tagsIDs string
|
||||
var tagsIDs []string
|
||||
|
||||
// TODO: frequent tags for novels are *not* fetched when CategoryAny or CategoryAnyAlt
|
||||
|
||||
// Since category is pre-validated, we don't need to handle unexpected categories
|
||||
if category == CategoryAny || category == CategoryAnyAlt || category == CategoryIllustration || category == CategoryManga {
|
||||
tagsIDs = illustrationIDs + mangaIDs
|
||||
} else {
|
||||
tagsIDs = novelIDs
|
||||
// Append illustrationIDs and mangaIDs if they are not empty
|
||||
if illustrationIDs != "" {
|
||||
tagsIDs = append(tagsIDs, illustrationIDs)
|
||||
}
|
||||
if mangaIDs != "" {
|
||||
tagsIDs = append(tagsIDs, mangaIDs)
|
||||
}
|
||||
} else if category == CategoryNovels {
|
||||
// Append novelIDs if not empty
|
||||
if novelIDs != "" {
|
||||
tagsIDs = append(tagsIDs, novelIDs)
|
||||
}
|
||||
}
|
||||
|
||||
user.FrequentTags, err = getUserFrequentTags(r, tagsIDs, category)
|
||||
if err != nil {
|
||||
return err
|
||||
if len(tagsIDs) == 0 {
|
||||
// No tags to fetch, set FrequentTags to empty slice
|
||||
user.FrequentTags = []FrequentTag{}
|
||||
} else {
|
||||
// Concatenate IDs with commas to form a single string
|
||||
ids := strings.Join(tagsIDs, ",")
|
||||
user.FrequentTags, err = getUserFrequentTags(r, ids, category)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get user frequent tags: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user