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,7 +9,7 @@ import { observer } from "mobx-react";
import { useTheme } from "next-themes";
// plane imports
import type { I_THEME_OPTION } from "@plane/constants";
import { THEME_OPTIONS } from "@plane/constants";
import { NODEDC_FORCED_THEME, NODEDC_THEME_LOCK_ENABLED, THEME_OPTIONS } from "@plane/constants";
import { useTranslation } from "@plane/i18n";
import { setPromiseToast } from "@plane/propel/toast";
import { applyCustomTheme } from "@plane/utils";
@@ -35,18 +35,20 @@ export const ThemeSwitcher = observer(function ThemeSwitcher(props: {
const { t } = useTranslation();
// derived values
const currentTheme = useMemo(() => {
const userThemeOption = THEME_OPTIONS.find((t) => t.value === userProfile?.theme?.theme);
return userThemeOption || null;
const themeValue = NODEDC_THEME_LOCK_ENABLED ? NODEDC_FORCED_THEME : userProfile?.theme?.theme;
return THEME_OPTIONS.find((themeOption) => themeOption.value === themeValue) || null;
}, [userProfile?.theme?.theme]);
const handleThemeChange = useCallback(
async (themeOption: I_THEME_OPTION) => {
try {
setTheme(themeOption.value);
const nextTheme = NODEDC_THEME_LOCK_ENABLED ? NODEDC_FORCED_THEME : themeOption.value;
setTheme(nextTheme);
// If switching to custom theme and user has saved custom colors, apply them immediately
if (
themeOption.value === "custom" &&
!NODEDC_THEME_LOCK_ENABLED &&
nextTheme === "custom" &&
userProfile?.theme?.primary &&
userProfile?.theme?.background &&
userProfile?.theme?.darkPalette !== undefined
@@ -58,7 +60,7 @@ export const ThemeSwitcher = observer(function ThemeSwitcher(props: {
);
}
const updatePromise = updateUserTheme({ theme: themeOption.value });
const updatePromise = updateUserTheme({ theme: nextTheme });
setPromiseToast(updatePromise, {
loading: "Updating theme...",
success: {
@@ -96,7 +98,7 @@ export const ThemeSwitcher = observer(function ThemeSwitcher(props: {
/>
}
/>
{userProfile.theme?.theme === "custom" && <CustomThemeSelector />}
{!NODEDC_THEME_LOCK_ENABLED && userProfile.theme?.theme === "custom" && <CustomThemeSelector />}
</>
);
});