Filter location tags
This commit is contained in:
parent
72fda72de5
commit
62e7ccf17b
5 changed files with 93 additions and 47 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
const {z} = require("zod")
|
||||
|
||||
const account = z.string().regex(/^[a-z0-9_-]+$/)
|
||||
|
||||
const schema = {
|
||||
appQuery: z.object({
|
||||
arrange: z.enum(["album", "artist", "label", "tag", "track"]),
|
||||
|
@ -11,11 +13,11 @@ const schema = {
|
|||
filter_fuzzy: z.enum(["true"]).optional()
|
||||
}),
|
||||
account: z.object({
|
||||
account: z.string().regex(/^[a-z0-9_-]+$/)
|
||||
account
|
||||
}),
|
||||
postCurrency: z.object({
|
||||
currency: z.string().regex(/^[A-Z]{3}$/),
|
||||
account: z.string()
|
||||
account
|
||||
}),
|
||||
play: z.object({
|
||||
item_type: z.enum(["album", "track"]),
|
||||
|
@ -24,6 +26,10 @@ const schema = {
|
|||
}),
|
||||
inlinePlayer: z.object({
|
||||
inline_player: z.string().optional()
|
||||
}),
|
||||
locationTags: z.object({
|
||||
location_tags: z.enum(["all", "hide", "only"]),
|
||||
account
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
const {sync, router} = require("../passthrough")
|
||||
const {defineEventHandler, readValidatedBody, setCookie, setResponseHeader} = require("h3")
|
||||
const {defineEventHandler, readValidatedBody, setCookie, setResponseHeader, sendRedirect} = require("h3")
|
||||
|
||||
/** @type {import("../pug-sync")} */
|
||||
const pugSync = sync.require("../pug-sync")
|
||||
|
||||
/** @type {import("./schema")} */
|
||||
const schema = sync.require("./schema")
|
||||
|
@ -12,3 +15,9 @@ router.post("/api/settings/inline-player", defineEventHandler(async event => {
|
|||
setResponseHeader(event, "HX-Refresh", "true")
|
||||
return null
|
||||
}))
|
||||
|
||||
router.post("/api/settings/location-tags", defineEventHandler(async event => {
|
||||
const {location_tags, account} = await readValidatedBody(event, schema.schema.locationTags.parse)
|
||||
setCookie(event, "bcex-location-tags", location_tags)
|
||||
return sendRedirect(event, `/${account}/?arrange=tag&shape=grid`)
|
||||
}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue