From: Scott <97430840+scme0@users.noreply.github.com> Date: Thu, 22 Jun 2023 12:55:11 +0000 (+0930) Subject: Fix buildThemeList() function to ensure no duplicates (#1466) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/%24%7Bsrc%7D?a=commitdiff_plain;h=0247f8a2cfa665d2ec96bbaa53cf9ed0f0c2ce9c;p=lemmy-ui.git Fix buildThemeList() function to ensure no duplicates (#1466) Co-authored-by: Dessalines --- 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; }