diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3211e1490..6ad4a1b3d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -169,7 +169,8 @@ e2e: artifacts: expire_in: 2 days paths: - - js/playwright-report + - js/playwright-report/ + - js/test-results/ pages: stage: deploy diff --git a/config/config.exs b/config/config.exs index b28988f38..fef8c6ddd 100644 --- a/config/config.exs +++ b/config/config.exs @@ -19,6 +19,7 @@ config :mobilizon, :instance, registrations_open: false, registration_email_allowlist: [], registration_email_denylist: [], + disable_database_login: false, languages: [], default_language: "en", demo: false, diff --git a/js/src/App.vue b/js/src/App.vue index 024eddd40..108981bb3 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -54,6 +54,7 @@ import { defineAsyncComponent, computed, watch, + onBeforeUnmount, } from "vue"; import { LocationType } from "@/types/user-location.model"; import { useMutation, useQuery } from "@vue/apollo-composable"; @@ -123,7 +124,7 @@ const interval = ref(0); const notifier = inject("notifier"); -interval.value = setInterval(async () => { +interval.value = window.setInterval(async () => { const accessToken = localStorage.getItem(AUTH_ACCESS_TOKEN); if (accessToken) { const token = jwt_decode(accessToken); @@ -155,6 +156,7 @@ onBeforeMount(async () => { }); const snackbar = inject("snackbar"); +const darkModePreference = window.matchMedia("(prefers-color-scheme: dark)"); onMounted(() => { online.value = window.navigator.onLine; @@ -187,6 +189,7 @@ onMounted(() => { }, }); }); + darkModePreference.addEventListener("change", changeTheme); }); onUnmounted(() => { @@ -289,6 +292,23 @@ watch(config, async (configWatched: IConfig | undefined) => { }); const isDemoMode = computed(() => config.value?.demoMode); + +const changeTheme = () => { + console.debug("changing theme"); + if ( + localStorage.getItem("theme") === "dark" || + (!("theme" in localStorage) && + window.matchMedia("(prefers-color-scheme: dark)").matches) + ) { + document.documentElement.classList.add("dark"); + } else { + document.documentElement.classList.remove("dark"); + } +}; + +onBeforeUnmount(() => { + darkModePreference.removeEventListener("change", changeTheme); +});