fix: temporarily lock tasker dark theme

This commit is contained in:
DCCONSTRUCTIONS
2026-05-23 10:32:04 +03:00
parent 3f86b73d5c
commit 6e74964853
10 changed files with 126 additions and 66 deletions
@@ -9,6 +9,7 @@ import { useEffect, useRef } from "react";
import { observer } from "mobx-react";
import { useParams } from "next/navigation";
import { useTheme } from "next-themes";
import { NODEDC_FORCED_THEME, NODEDC_THEME_LOCK_ENABLED } from "@plane/constants";
import type { TLanguage } from "@plane/i18n";
import { DEFAULT_LANGUAGE, useTranslation } from "@plane/i18n";
// helpers
@@ -57,16 +58,13 @@ function StoreWrapper(props: TStoreWrapper) {
*/
useEffect(() => {
const localValue = localStorage && localStorage.getItem("app_sidebar_collapsed");
const localBoolValue = localValue ? (localValue === "true" ? true : false) : false;
const localBoolValue = localValue === "true";
if (localValue && sidebarCollapsed === undefined) toggleSidebar(localBoolValue);
}, [sidebarCollapsed, setTheme, toggleSidebar]);
/**
* Effect 1: Initial theme sync from server (one-time only)
*
* This effect runs ONCE per user session to load theme from server.
* After initial load, all theme changes are localStorage-driven (next-themes).
* This prevents a feedback loop where server updates trigger UI updates in a cycle.
* Temporary NODE.DC theme lock: keep the operational dark palette active
* until the light theme gets a full pass.
*/
useEffect(() => {
const userId = userProfile?.id;
@@ -79,6 +77,16 @@ function StoreWrapper(props: TStoreWrapper) {
currentUserIdRef.current = userId;
}
if (NODEDC_THEME_LOCK_ENABLED) {
if (!userProfile?.id || hasInitializedThemeRef.current) {
return;
}
setTheme(NODEDC_FORCED_THEME);
hasInitializedThemeRef.current = true;
return;
}
// Only initialize theme from server on FIRST load for this user
if (!userProfile?.theme?.theme || hasInitializedThemeRef.current) {
return; // Skip if already initialized or no profile data
@@ -89,7 +97,7 @@ function StoreWrapper(props: TStoreWrapper) {
// Mark as initialized - prevents future syncs from server
hasInitializedThemeRef.current = true;
}, [userProfile?.theme?.theme, setTheme]);
}, [userProfile?.id, userProfile?.theme?.theme, setTheme]);
/**
* Effect 2: Custom theme CSS application (runs on every change)
@@ -98,12 +106,21 @@ function StoreWrapper(props: TStoreWrapper) {
* the theme changes. It runs independently of the initial sync effect.
*/
useEffect(() => {
if (!userProfile?.theme?.theme) return;
if (NODEDC_THEME_LOCK_ENABLED) {
clearCustomTheme();
return;
}
if (!userProfile?.theme?.theme) {
return;
}
const currentTheme = userProfile?.theme?.theme;
const previousTheme = previousThemeRef.current;
const themeData = userProfile?.theme;
if (!currentTheme) return;
// Apply custom theme if current theme is custom
if (currentTheme === "custom" && themeData.primary && themeData.background && themeData.darkPalette !== undefined) {
applyCustomTheme(themeData.primary, themeData.background, themeData.darkPalette ? "dark" : "light");
@@ -116,7 +133,7 @@ function StoreWrapper(props: TStoreWrapper) {
// Update previous theme for next comparison
previousThemeRef.current = currentTheme;
}, [userProfile?.theme]);
}, [userProfile?.id, userProfile?.theme]);
useEffect(() => {
if (!userProfile?.id) return;
@@ -138,7 +155,7 @@ function StoreWrapper(props: TStoreWrapper) {
useEffect(() => {
if (!userProfile?.id) return;
changeLanguage((userProfile?.language as TLanguage) || DEFAULT_LANGUAGE);
}, [userProfile?.language, changeLanguage]);
}, [userProfile?.id, userProfile?.language, changeLanguage]);
useEffect(() => {
if (!params) return;