Reorder parameter defintions

Order matters for URL generation. Important options should be up front.
This commit is contained in:
Marcel Hellkamp 2023-08-04 11:11:31 +02:00
parent 4294f3a9a7
commit 7c0d42c929

View File

@ -75,7 +75,12 @@ const parameterDefinitions: Array<ParamDef> = [
}, },
}, },
// Filter options // Content filters
{
names: ["lang", "l"],
from: (config: Partial<Config>, value: string) => config.languages = value.split(","),
to: (config: Config) => (config.languages || []).join(","),
},
{ {
names: ["hide"], names: ["hide"],
from: (config: Partial<Config>, value: string) => { from: (config: Partial<Config>, value: string) => {
@ -94,27 +99,24 @@ const parameterDefinitions: Array<ParamDef> = [
return flags.join(",") return flags.join(",")
}, },
}, },
{
names: ["lang", "l"],
from: (config: Partial<Config>, value: string) => config.languages = value.split(","),
to: (config: Config) => (config.languages || []).join(","),
},
{ {
names: ["ban"], names: ["ban"],
from: (config: Partial<Config>, value: string) => config.badWords = value.split(","), from: (config: Partial<Config>, value: string) => config.badWords = value.split(","),
to: (config: Config) => (config.badWords || []).join(","), to: (config: Config) => (config.badWords || []).join(","),
}, },
{
names: ["text"],
from: (config: Partial<Config>, value: string) => config.showText = fromBool(value),
to: (config: Config) => toBool(config.showText),
},
{
names: ["media"],
from: (config: Partial<Config>, value: string) => config.showMedia = fromBool(value),
to: (config: Config) => toBool(config.showMedia),
},
// Visuals
{
names: ["limit"],
from: (config: Partial<Config>, value: string) => config.limit = parseInt(value),
to: (config: Config) => config.limit.toString(),
},
{
names: ["interval"],
from: (config: Partial<Config>, value: string) => config.interval = parseInt(value),
to: (config: Config) => config.interval.toString(),
},
{ {
names: ["title"], names: ["title"],
from: (config: Partial<Config>, value: string) => config.title = value.trim(), from: (config: Partial<Config>, value: string) => config.title = value.trim(),
@ -130,21 +132,25 @@ const parameterDefinitions: Array<ParamDef> = [
from: (config: Partial<Config>, value: string) => config.showInfobar = fromBool(value), from: (config: Partial<Config>, value: string) => config.showInfobar = fromBool(value),
to: (config: Config) => toBool(config.showInfobar), to: (config: Config) => toBool(config.showInfobar),
}, },
{
names: ["text"],
from: (config: Partial<Config>, value: string) => config.showText = fromBool(value),
to: (config: Config) => toBool(config.showText),
},
{
names: ["media"],
from: (config: Partial<Config>, value: string) => config.showMedia = fromBool(value),
to: (config: Config) => toBool(config.showMedia),
},
{ {
names: ["autoplay"], names: ["autoplay"],
from: (config: Partial<Config>, value: string) => config.playVideos = fromBool(value), from: (config: Partial<Config>, value: string) => config.playVideos = fromBool(value),
to: (config: Config) => toBool(config.playVideos), to: (config: Config) => toBool(config.playVideos),
}] },
// Other settings
{
names: ["limit"],
from: (config: Partial<Config>, value: string) => config.limit = parseInt(value),
to: (config: Config) => config.limit.toString(),
},
{
names: ["interval"],
from: (config: Partial<Config>, value: string) => config.interval = parseInt(value),
to: (config: Config) => config.interval.toString(),
},
]
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
parameterDefinitions.flatMap(p => p.names).filter((v, i, a) => { parameterDefinitions.flatMap(p => p.names).filter((v, i, a) => {