From 7c0d42c929ae63b7dc6b0226788b72732d3b4dc5 Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Fri, 4 Aug 2023 11:11:31 +0200 Subject: [PATCH] Reorder parameter defintions Order matters for URL generation. Important options should be up front. --- src/config.ts | 60 ++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/config.ts b/src/config.ts index 609eae7..11bd97a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -75,7 +75,12 @@ const parameterDefinitions: Array = [ }, }, - // Filter options + // Content filters + { + names: ["lang", "l"], + from: (config: Partial, value: string) => config.languages = value.split(","), + to: (config: Config) => (config.languages || []).join(","), + }, { names: ["hide"], from: (config: Partial, value: string) => { @@ -94,27 +99,24 @@ const parameterDefinitions: Array = [ return flags.join(",") }, }, - { - names: ["lang", "l"], - from: (config: Partial, value: string) => config.languages = value.split(","), - to: (config: Config) => (config.languages || []).join(","), - }, { names: ["ban"], from: (config: Partial, value: string) => config.badWords = value.split(","), to: (config: Config) => (config.badWords || []).join(","), }, + { + names: ["text"], + from: (config: Partial, value: string) => config.showText = fromBool(value), + to: (config: Config) => toBool(config.showText), + }, + { + names: ["media"], + from: (config: Partial, value: string) => config.showMedia = fromBool(value), + to: (config: Config) => toBool(config.showMedia), + }, + + // Visuals - { - names: ["limit"], - from: (config: Partial, value: string) => config.limit = parseInt(value), - to: (config: Config) => config.limit.toString(), - }, - { - names: ["interval"], - from: (config: Partial, value: string) => config.interval = parseInt(value), - to: (config: Config) => config.interval.toString(), - }, { names: ["title"], from: (config: Partial, value: string) => config.title = value.trim(), @@ -130,21 +132,25 @@ const parameterDefinitions: Array = [ from: (config: Partial, value: string) => config.showInfobar = fromBool(value), to: (config: Config) => toBool(config.showInfobar), }, - { - names: ["text"], - from: (config: Partial, value: string) => config.showText = fromBool(value), - to: (config: Config) => toBool(config.showText), - }, - { - names: ["media"], - from: (config: Partial, value: string) => config.showMedia = fromBool(value), - to: (config: Config) => toBool(config.showMedia), - }, { names: ["autoplay"], from: (config: Partial, value: string) => config.playVideos = fromBool(value), to: (config: Config) => toBool(config.playVideos), - }] + }, + + // Other settings + + { + names: ["limit"], + from: (config: Partial, value: string) => config.limit = parseInt(value), + to: (config: Config) => config.limit.toString(), + }, + { + names: ["interval"], + from: (config: Partial, value: string) => config.interval = parseInt(value), + to: (config: Config) => config.interval.toString(), + }, +] if (import.meta.env.DEV) { parameterDefinitions.flatMap(p => p.names).filter((v, i, a) => {