feat: add updateActiveProject function for in-place project updates

This commit is contained in:
Dries Augustyns
2026-04-24 14:58:06 +02:00
parent 98f1e80fca
commit 6f31fa2503
3 changed files with 57 additions and 45 deletions
@@ -7,6 +7,7 @@ import {useProjects} from '../hooks/useProject';
interface ActiveProjectContextValue {
activeProject: Project | null;
setActiveProject: (project: Project) => void;
updateActiveProject: (project: Project) => void;
availableProjects: Project[];
isLoading: boolean;
}
@@ -55,9 +56,16 @@ export function ActiveProjectProvider({children}: {children: ReactNode}) {
void mutate(() => true, undefined, {revalidate: true});
};
// Updates the active project's data in-place without invalidating the SWR cache.
// Use this when saving settings for the current project, not when switching projects.
const updateActiveProject = (project: Project) => {
setActiveProjectState(project);
};
const value: ActiveProjectContextValue = {
activeProject,
setActiveProject,
updateActiveProject,
availableProjects: projects ?? [],
isLoading,
};