[FEAT] Save name fix

This commit is contained in:
2026-01-01 19:20:16 +01:00
parent a314721a60
commit 934b6cba9b
6 changed files with 197 additions and 45 deletions

View File

@@ -69,15 +69,29 @@ export const useProjectManager = () => {
try {
const data = await generateProjectJSON();
if (projectStore.currentProject && projectStore.currentProject.name === name) {
await projectStore.updateProject(projectStore.currentProject.id, data);
if (projectStore.currentProject) {
// Update existing project (even if name changed)
await projectStore.updateProject(projectStore.currentProject.id, name, data);
} else {
// Create new project if none exists
await projectStore.createProject(name, data);
}
} catch (e) {
console.error(e);
alert('Failed to save project');
throw e; // Re-throw to let caller know
throw e;
}
};
const saveAsProject = async (name: string) => {
try {
const data = await generateProjectJSON();
// Always create new
await projectStore.createProject(name, data);
} catch (e) {
console.error(e);
alert('Failed to save project as new');
throw e;
}
};
@@ -90,6 +104,8 @@ export const useProjectManager = () => {
createProject,
openProject,
saveProject,
saveAsProject,
closeEditor,
loadProjectData,
};
};