Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add a function to get the "base" theme for a theme #3615

Merged
merged 1 commit into from
Nov 14, 2019

Conversation

turt2live
Copy link
Member

Useful for trying to load the right assets first.

Please review with element-hq/element-web#11381

Useful for trying to load the right assets first. 

See element-hq/element-web#11381
Copy link
Collaborator

@jryans jryans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 😁

*/
export function getBaseTheme(theme) {
if (!theme) return "light";
if (theme.startsWith("custom-")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTheme in the same module shares a lot of this code... Any chance to de-duplicate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's much better... thoughts?

diff --git a/src/theme.js b/src/theme.js
index 8a15c606d..b346a915b 100644
--- a/src/theme.js
+++ b/src/theme.js
@@ -85,10 +85,9 @@ export function setTheme(theme) {
     if (!theme) {
         theme = SettingsStore.getValue("theme");
     }
-    let stylesheetName = theme;
-    if (theme.startsWith("custom-")) {
+    let stylesheetName = getBaseTheme(theme);
+    if (stylesheetName.endsWith("-custom")) {
         const customTheme = getCustomTheme(theme.substr(7));
-        stylesheetName = customTheme.is_dark ? "dark-custom" : "light-custom";
         setCustomThemeVars(customTheme);
     }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, alright, let's go with what you had then! Thanks for checking it out. 😄

@turt2live turt2live merged commit 4258a82 into develop Nov 14, 2019
@turt2live turt2live deleted the travis/base-theme branch November 14, 2019 16:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants