Skip to content

Commit

Permalink
Clear state on project load
Browse files Browse the repository at this point in the history
  • Loading branch information
abrenneke committed Aug 8, 2024
1 parent ad3088a commit 8461ba8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/app/src/hooks/useLoadProject.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSetRecoilState } from 'recoil';
import { type OpenedProjectInfo, loadedProjectState, projectState } from '../state/savedGraphs.js';
import { emptyNodeGraph, getError } from '@ironclad/rivet-core';
import { graphState } from '../state/graph.js';
import { graphState, historicalGraphState, isReadOnlyGraphState } from '../state/graph.js';
import { ioProvider } from '../utils/globals.js';
import { trivetState } from '../state/trivet.js';
import { useSetStaticData } from './useSetStaticData';
Expand All @@ -15,13 +15,18 @@ export function useLoadProject() {
const setTrivetState = useSetRecoilState(trivetState);
const setStaticData = useSetStaticData();
const setNavigationStack = useSetRecoilState(graphNavigationStackState);
const setIsReadOnlyGraph = useSetRecoilState(isReadOnlyGraphState);
const setHistoricalGraph = useSetRecoilState(historicalGraphState);

return async (projectInfo: OpenedProjectInfo) => {
try {
setProject(projectInfo.project);

setNavigationStack({ stack: [], index: undefined });

setIsReadOnlyGraph(false);
setHistoricalGraph(null);

if (projectInfo.openedGraph) {
const graphData = projectInfo.project.graphs[projectInfo.openedGraph];
if (graphData) {
Expand Down

0 comments on commit 8461ba8

Please sign in to comment.