From 0247f8a2cfa665d2ec96bbaa53cf9ed0f0c2ce9c Mon Sep 17 00:00:00 2001 From: Scott <97430840+scme0@users.noreply.github.com> Date: Thu, 22 Jun 2023 22:25:11 +0930 Subject: [PATCH] Fix buildThemeList() function to ensure no duplicates (#1466) Co-authored-by: Dessalines --- src/server/utils/build-themes-list.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/server/utils/build-themes-list.ts b/src/server/utils/build-themes-list.ts index 73dc53b..74b910c 100644 --- a/src/server/utils/build-themes-list.ts +++ b/src/server/utils/build-themes-list.ts @@ -4,15 +4,20 @@ import { readdir } from "fs/promises"; const extraThemesFolder = process.env["LEMMY_UI_EXTRA_THEMES_FOLDER"] || "./extra_themes"; -const themes = ["darkly", "darkly-red", "litely", "litely-red"]; +const themes: ReadonlyArray = [ + "darkly", + "darkly-red", + "litely", + "litely-red", +]; -export async function buildThemeList(): Promise { +export async function buildThemeList(): Promise> { if (existsSync(extraThemesFolder)) { const dirThemes = await readdir(extraThemesFolder); const cssThemes = dirThemes .filter(d => d.endsWith(".css")) .map(d => d.replace(".css", "")); - themes.push(...cssThemes); + return themes.concat(cssThemes); } return themes; } -- 2.44.1