You've already forked AstralRinth
forked from didirus/AstralRinth
Fix Discover URL filter parsing, improve search sidebar (#5104)
* fix category parsing on discover * Make categories (loader, platform, etc) colored in discover, also add i18n * fix formatting * add localized strings --------- Co-authored-by: Creeperkatze <178587183+Creeperkatze@users.noreply.github.com> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
@@ -558,32 +558,45 @@ export function useSearch(
|
||||
})
|
||||
|
||||
for (const key of Object.keys(route.query).filter((key) => !readParams.has(key))) {
|
||||
const type = filters.value.find((type) => type.query_param === key)
|
||||
if (type) {
|
||||
const values = getParamValuesAsArray(route.query[key])
|
||||
const types = filters.value.filter((type) => type.query_param === key)
|
||||
if (types.length === 0) {
|
||||
console.error(`Unknown filter type: ${key}`)
|
||||
continue
|
||||
}
|
||||
|
||||
for (const value of values) {
|
||||
const negative = !value.includes(':') && value.includes('!=')
|
||||
const values = getParamValuesAsArray(route.query[key])
|
||||
|
||||
for (const value of values) {
|
||||
const negative = !value.includes(':') && value.includes('!=')
|
||||
let matched = false
|
||||
|
||||
for (const type of types) {
|
||||
const option = type.options.find((option) => getOptionValue(option, negative) === value)
|
||||
if (!option) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (!option && type.allows_custom_options) {
|
||||
currentFilters.value.push({
|
||||
type: type.id,
|
||||
option: option.id,
|
||||
negative: negative,
|
||||
})
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
|
||||
if (!matched) {
|
||||
const customType = types.find((type) => type.allows_custom_options)
|
||||
if (customType) {
|
||||
currentFilters.value.push({
|
||||
type: type.id,
|
||||
type: customType.id,
|
||||
option: value.replace('!=', ':'),
|
||||
negative: negative,
|
||||
})
|
||||
} else if (option) {
|
||||
currentFilters.value.push({
|
||||
type: type.id,
|
||||
option: option.id,
|
||||
negative: negative,
|
||||
})
|
||||
} else {
|
||||
console.error(`Unknown filter option: ${value}`)
|
||||
console.error(`Unknown filter option for ${key}: ${value}`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.error(`Unknown filter type: ${key}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user