]> Untitled Git - lemmy-ui.git/commitdiff
Fix buildThemeList() function to ensure no duplicates (#1466)
authorScott <97430840+scme0@users.noreply.github.com>
Thu, 22 Jun 2023 12:55:11 +0000 (22:25 +0930)
committerGitHub <noreply@github.com>
Thu, 22 Jun 2023 12:55:11 +0000 (08:55 -0400)
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
src/server/utils/build-themes-list.ts

index 73dc53bcad4d3df324c7e436a8d520da7ef2c5cb..74b910c767d86ed24973886adb4d387a05dd5b0e 100644 (file)
@@ -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<string> = [
+  "darkly",
+  "darkly-red",
+  "litely",
+  "litely-red",
+];
 
-export async function buildThemeList(): Promise<string[]> {
+export async function buildThemeList(): Promise<ReadonlyArray<string>> {
   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;
 }