Skip to content

Commit

Permalink
fixes LUNA-212 Failing to save should have an error toast!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
ShravanSunder committed Mar 24, 2024
1 parent bf768f4 commit 2137b3f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 30 deletions.
66 changes: 38 additions & 28 deletions packages/app/src/hooks/useSaveProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@ export function useSaveProject() {
saving = toast.info('Saving project');
}, 500);

await ioProvider.saveProjectDataNoPrompt(newProject, { testSuites }, loadedProject.path);
try {
await ioProvider.saveProjectDataNoPrompt(newProject, { testSuites }, loadedProject.path);

if (saving != null) {
toast.dismiss(saving);
}
clearTimeout(savingTimeout);
if (saving != null) {
toast.dismiss(saving);
}
clearTimeout(savingTimeout);

toast.success('Project saved');
setLoadedProject({
loaded: true,
path: loadedProject.path,
});
toast.success('Project saved');
setLoadedProject({
loaded: true,
path: loadedProject.path,
});
} catch (cause) {
clearTimeout(savingTimeout);
toast.error('Failed to save project');
}
}

async function saveProjectAs() {
Expand All @@ -57,26 +62,31 @@ export function useSaveProject() {
saving = toast.info('Saving project');
}, 500);

const filePath = await ioProvider.saveProjectData(newProject, { testSuites });
try {
const filePath = await ioProvider.saveProjectData(newProject, { testSuites });

if (saving != null) {
toast.dismiss(saving);
}
clearTimeout(savingTimeout);
if (saving != null) {
toast.dismiss(saving);
}
clearTimeout(savingTimeout);

if (filePath) {
toast.success('Project saved');
setLoadedProject({
loaded: true,
path: filePath,
});
setOpenedProjects((projects) => ({
...projects,
[project.metadata.id]: {
project,
fsPath: filePath,
},
}));
if (filePath) {
toast.success('Project saved');
setLoadedProject({
loaded: true,
path: filePath,
});
setOpenedProjects((projects) => ({
...projects,
[project.metadata.id]: {
project,
fsPath: filePath,
},
}));
}
} catch (cause) {
clearTimeout(savingTimeout);
toast.error('Failed to save project');
}
}

Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/utils/serialization/serialization_v4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ export function graphV4Deserializer(data: unknown): NodeGraph {

export function projectV4Serializer(project: Project, attachedData?: AttachedData): unknown {
const filteredProject = {
...project
...project,
metadata: {
...project.metadata,
path: undefined,
}
}
delete filteredProject.metadata.path;

// Make sure all data is ordered deterministically first
const stabilized = JSON.parse(stableStringify(toSerializedProject(filteredProject, attachedData)));
Expand Down

0 comments on commit 2137b3f

Please sign in to comment.