From 004c954cd17724f212bdbf0b15f632ea713b04c6 Mon Sep 17 00:00:00 2001 From: Alex Anderson Date: Wed, 15 Feb 2023 19:57:52 -0500 Subject: [PATCH] fix: If a ship doesn't have a theme assigned to it, only automatically assign themes marked as default. --- client/src/data/flight.ts | 4 +++- server/src/classes/Plugins/Theme.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/src/data/flight.ts b/client/src/data/flight.ts index fddf537b..9d5dbb8a 100644 --- a/client/src/data/flight.ts +++ b/client/src/data/flight.ts @@ -287,7 +287,9 @@ export const flight = t.router({ theme = activePlugins.reduce( (acc: {pluginId: string; themeId: string} | null, plugin) => { if (acc) return acc; - const theme = plugin.aspects?.themes?.[0]; + const theme = plugin.aspects?.themes?.filter( + theme => theme.default + )[0]; if (!theme) return null; return {pluginId: plugin.id, themeId: theme.name}; }, diff --git a/server/src/classes/Plugins/Theme.ts b/server/src/classes/Plugins/Theme.ts index c9125366..b67e7d2a 100644 --- a/server/src/classes/Plugins/Theme.ts +++ b/server/src/classes/Plugins/Theme.ts @@ -14,7 +14,7 @@ export default class ThemePlugin extends Aspect { apiVersion = "theme/v1" as const; kind = "themes" as const; name: string; - + default?: boolean; assets: { rawCSS: string; processedCSS: string; @@ -34,6 +34,7 @@ export default class ThemePlugin extends Aspect { processedCSS: "processed.css", files: [], }; + this.default = params.default || false; } async setCSS(rawCSS: string) {