diff --git a/src/api/mods.js b/src/api/mods.js index fb51fc4..8818b51 100644 --- a/src/api/mods.js +++ b/src/api/mods.js @@ -24,15 +24,15 @@ const getMods = async () => { }, getThemes = async () => { const mods = await getMods(); - return mods.find(({ _src }) => _src.startsWith("themes/")); + return mods.filter(({ _src }) => _src.startsWith("themes/")); }, getExtensions = async () => { const mods = await getMods(); - return mods.find(({ _src }) => _src.startsWith("extensions/")); + return mods.filter(({ _src }) => _src.startsWith("extensions/")); }, getIntegrations = async () => { const mods = await getMods(); - return mods.find(({ _src }) => _src.startsWith("integrations/")); + return mods.filter(({ _src }) => _src.startsWith("integrations/")); }; const getProfile = async () => { diff --git a/src/core/client.mjs b/src/core/client.mjs index 9d54d90..bd4ffe6 100644 --- a/src/core/client.mjs +++ b/src/core/client.mjs @@ -7,8 +7,17 @@ const notionSidebar = `.notion-sidebar-container .notion-sidebar > :nth-child(3) > div > :nth-child(2)`; export default async (api, db) => { - const { platform, enhancerUrl, onMessage, sendMessage } = api, - { html, addMutationListener, addKeyListener } = api, + const { + html, + platform, + getThemes, + isEnabled, + enhancerUrl, + onMessage, + sendMessage, + addMutationListener, + addKeyListener, + } = api, openMenuHotkey = await db.get("openMenuHotkey"), menuButtonIconStyle = await db.get("menuButtonIconStyle"), loadThemeOverrides = await db.get("loadThemeOverrides"), @@ -16,7 +25,12 @@ export default async (api, db) => { // appearance - if (loadThemeOverrides) { + const enabledThemes = (await getThemes()).map((theme) => isEnabled(theme.id)), + forceLoadOverrides = loadThemeOverrides === "Enabled", + autoLoadOverrides = + loadThemeOverrides === "Auto" && + (await Promise.all(enabledThemes)).some((enabled) => enabled); + if (forceLoadOverrides || autoLoadOverrides) { document.head.append(html` { >
diff --git a/src/core/mod.json b/src/core/mod.json index 26dcd54..d3fd098 100644 --- a/src/core/mod.json +++ b/src/core/mod.json @@ -30,13 +30,13 @@ "type": "select", "key": "menuButtonIconStyle", "description": "Sets whether the notion-enhancer icon added to Notion's sidebar should be coloured or monochrome. The latter style will match the theme's icon colour for users who would like the icon to be less noticeable.", - "values": ["colour", "monochrome"] + "values": ["Colour", "Monochrome"] }, { - "type": "toggle", + "type": "select", "key": "loadThemeOverrides", - "description": "Loads the styling required for a theme to customise Notion's interface. Turning this off will disable all themes but may increase client performance.", - "value": true + "description": "Loads the styling required for a theme to customise Notion's interface. Disabling this will increase client performance.", + "values": ["Auto", "Enabled", "Disabled"] }, { "type": "file",