mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
fix themes
This commit is contained in:
@@ -210,6 +210,7 @@ export function Sidebar() {
|
|||||||
cycleNextProject,
|
cycleNextProject,
|
||||||
clearProjectHistory,
|
clearProjectHistory,
|
||||||
setProjectTheme,
|
setProjectTheme,
|
||||||
|
setTheme,
|
||||||
theme: globalTheme,
|
theme: globalTheme,
|
||||||
} = useAppStore();
|
} = useAppStore();
|
||||||
|
|
||||||
@@ -430,12 +431,16 @@ export function Sidebar() {
|
|||||||
);
|
);
|
||||||
useAppStore.setState({ projects: updatedProjects });
|
useAppStore.setState({ projects: updatedProjects });
|
||||||
} else {
|
} else {
|
||||||
// Create new project
|
// Create new project - check for trashed project with same path first (preserves theme if deleted/recreated)
|
||||||
|
// Then fall back to current effective theme, then global theme
|
||||||
|
const trashedProject = trashedProjects.find((p) => p.path === path);
|
||||||
|
const effectiveTheme = trashedProject?.theme || currentProject?.theme || globalTheme;
|
||||||
project = {
|
project = {
|
||||||
id: `project-${Date.now()}`,
|
id: `project-${Date.now()}`,
|
||||||
name,
|
name,
|
||||||
path,
|
path,
|
||||||
lastOpened: new Date().toISOString(),
|
lastOpened: new Date().toISOString(),
|
||||||
|
theme: effectiveTheme,
|
||||||
};
|
};
|
||||||
addProject(project);
|
addProject(project);
|
||||||
}
|
}
|
||||||
@@ -474,7 +479,7 @@ export function Sidebar() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [projects, addProject, setCurrentProject]);
|
}, [projects, trashedProjects, addProject, setCurrentProject, currentProject, globalTheme]);
|
||||||
|
|
||||||
const handleRestoreProject = useCallback(
|
const handleRestoreProject = useCallback(
|
||||||
(projectId: string) => {
|
(projectId: string) => {
|
||||||
@@ -963,6 +968,10 @@ export function Sidebar() {
|
|||||||
value={currentProject.theme || ""}
|
value={currentProject.theme || ""}
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
if (currentProject) {
|
if (currentProject) {
|
||||||
|
// If selecting an actual theme (not "Use Global"), also update global
|
||||||
|
if (value !== "") {
|
||||||
|
setTheme(value as any);
|
||||||
|
}
|
||||||
setProjectTheme(
|
setProjectTheme(
|
||||||
currentProject.id,
|
currentProject.id,
|
||||||
value === "" ? null : (value as any)
|
value === "" ? null : (value as any)
|
||||||
|
|||||||
@@ -82,12 +82,14 @@ export function SettingsView() {
|
|||||||
// Compute the effective theme for the current project
|
// Compute the effective theme for the current project
|
||||||
const effectiveTheme = (settingsProject?.theme || theme) as Theme;
|
const effectiveTheme = (settingsProject?.theme || theme) as Theme;
|
||||||
|
|
||||||
// Handler to set theme - saves to project if one is selected, otherwise to global
|
// Handler to set theme - always updates global theme (user's preference),
|
||||||
|
// and also sets per-project theme if a project is selected
|
||||||
const handleSetTheme = (newTheme: typeof theme) => {
|
const handleSetTheme = (newTheme: typeof theme) => {
|
||||||
|
// Always update global theme so user's preference persists across all projects
|
||||||
|
setTheme(newTheme);
|
||||||
|
// Also set per-project theme if a project is selected
|
||||||
if (currentProject) {
|
if (currentProject) {
|
||||||
setProjectTheme(currentProject.id, newTheme);
|
setProjectTheme(currentProject.id, newTheme);
|
||||||
} else {
|
|
||||||
setTheme(newTheme);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -636,6 +636,7 @@ export const useAppStore = create<AppState & AppActions>()(
|
|||||||
name: trashed.name,
|
name: trashed.name,
|
||||||
path: trashed.path,
|
path: trashed.path,
|
||||||
lastOpened: new Date().toISOString(),
|
lastOpened: new Date().toISOString(),
|
||||||
|
theme: trashed.theme, // Preserve theme from trashed project
|
||||||
};
|
};
|
||||||
|
|
||||||
set({
|
set({
|
||||||
|
|||||||
Reference in New Issue
Block a user