Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

fix: load the right app theme color on startup or reload of PWA (#761)

Smauga2e89375f12f
diff --git a/frontend/app/composables/useAppColors.ts b/frontend/app/composables/useAppColors.ts
index 3044aa92..eff5d1d8 100644
--- a/frontend/app/composables/useAppColors.ts
+++ b/frontend/app/composables/useAppColors.ts
@@ -12,6 +12,7 @@ function setAppColor(color: string | number) {
if (typeof color === 'number') {
color = getAppAccent(color);
}
+ console.log('Setting app color to:', color);
if (!import.meta.client) return;
setThemeColor(`--${color}`);
if (color === 'primary') color = 'accent';
@@ -25,20 +26,17 @@ function setAppColor(color: string | number) {
document.body.style.colorScheme = colorMode.preference;
}
+const themeColor = ref('#3956e7');
+
function setThemeColor(cssVar: string) {
- let meta = document.querySelector('meta[name="theme-color"]');
- if (!meta) {
- meta = document.createElement('meta');
- meta.setAttribute('name', 'theme-color');
- document.head.appendChild(meta);
- }
const computedColor = getComputedStyle(document.documentElement).getPropertyValue(cssVar).trim();
- meta.setAttribute('content', computedColor);
+ themeColor.value = computedColor;
}
export const useAppColors = () => {
return {
getAppAccent,
setAppColor,
+ themeColor,
};
};
diff --git a/frontend/app/pages/dashboard.vue b/frontend/app/pages/dashboard.vue
index d1231d9a..64c7c918 100644
--- a/frontend/app/pages/dashboard.vue
+++ b/frontend/app/pages/dashboard.vue
@@ -15,7 +15,7 @@ const nodesStore = useNodesStore();
const userStore = useUserStore();
const preferences = usePreferencesStore();
-const { setAppColor } = useAppColors();
+const { setAppColor, themeColor } = useAppColors();
const { locale: i18nLocale, loadLocaleMessages } = useI18n();
const { isLoading } = useAppState();
useStyleInjection(); // Custom styles for the app and documents
@@ -34,6 +34,15 @@ watch(
{ immediate: true },
);
+useHead({
+ meta: [
+ {
+ name: 'theme-color',
+ content: themeColor,
+ },
+ ],
+});
+
watch(
interfaceStyle,
style => {