fix: Ensure color theme syncs correctly by updating useEffect dependencies, refactor email base URL assignment, and add baseline-browser-mapping dependency.

This commit is contained in:
2025-11-29 03:16:46 -05:00
parent 03579bc625
commit e27877c477
6 changed files with 17 additions and 11 deletions

View File

@@ -49,12 +49,7 @@ export function ColorThemeProvider({
const updateThemeMutation = api.settings.updateTheme.useMutation();
// Sync from DB when available
React.useEffect(() => {
if (dbTheme) {
setColorTheme(dbTheme.colorTheme, dbTheme.customColor);
}
}, [dbTheme]);
const setColorTheme = React.useCallback(
(theme: ColorTheme, customColor?: string) => {
@@ -131,6 +126,13 @@ export function ColorThemeProvider({
[modeTheme, defaultColorTheme],
);
// Sync from DB when available
React.useEffect(() => {
if (dbTheme) {
setColorTheme(dbTheme.colorTheme, dbTheme.customColor);
}
}, [dbTheme, setColorTheme]);
// Effect to trigger DB update when state changes (debounced or direct)
// We do this separately to avoid putting mutation in the setColorTheme callback dependencies if possible
// But actually, calling it in setColorTheme is better for direct user action.