diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx
index 0898ad58d..7ccb9d1c7 100644
--- a/src/frontend/src/App.tsx
+++ b/src/frontend/src/App.tsx
@@ -16,7 +16,6 @@ import {
FETCH_ERROR_MESSAGE,
} from "./constants/constants";
import { alertContext } from "./contexts/alertContext";
-import { FlowsContext } from "./contexts/flowsContext";
import { locationContext } from "./contexts/locationContext";
import { typesContext } from "./contexts/typesContext";
import Router from "./routes";
@@ -30,7 +29,6 @@ export default function App() {
setShowSideBar(true);
setIsStackedOpen(true);
}, [location.pathname, setCurrent, setIsStackedOpen, setShowSideBar]);
- const { hardReset } = useContext(FlowsContext);
const {
errorData,
@@ -136,10 +134,7 @@ export default function App() {
{
- window.localStorage.removeItem("tabsData");
- window.localStorage.clear();
- hardReset();
- window.location.href = window.location.href;
+ // any reset function
}}
FallbackComponent={CrashErrorComponent}
>
diff --git a/src/frontend/src/contexts/flowsContext.tsx b/src/frontend/src/contexts/flowsContext.tsx
index e63222cd2..37182244a 100644
--- a/src/frontend/src/contexts/flowsContext.tsx
+++ b/src/frontend/src/contexts/flowsContext.tsx
@@ -64,6 +64,7 @@ import { typesContext } from "./typesContext";
const uid = new ShortUniqueId({ length: 5 });
const FlowsContextInitialValue: FlowsContextType = {
+ //Remove tab id and get current id from url
tabId: "",
setTabId: (index: string) => {},
isLoading: true,
@@ -83,7 +84,6 @@ const FlowsContextInitialValue: FlowsContextType = {
uploadFlow: async () => "",
isBuilt: false,
setIsBuilt: (state: boolean) => {},
- hardReset: () => {},
saveFlow: async (flow?: FlowType, silent?: boolean) => {},
lastCopiedSelection: null,
setLastCopiedSelection: (selection: any) => {},
@@ -209,12 +209,6 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
setEdgesInternal(newChange);
};
- useEffect(() => {
- if (!isAuthenticated) {
- hardReset();
- }
- }, [isAuthenticated]);
-
const newNodeId = useRef(uid());
function incrementNodeId() {
@@ -295,14 +289,6 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
setFlows(tabsData);
}
- function hardReset() {
- newNodeId.current = uid();
- setTabId("");
- setFlows([]);
- setIsLoading(true);
- setId(uid());
- }
-
/**
* Downloads the current flow as a JSON file
*/
@@ -799,7 +785,6 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
setIsBuilt,
lastCopiedSelection,
setLastCopiedSelection,
- hardReset,
tabId,
setTabId,
flows,
diff --git a/src/frontend/src/stores/flowManagerStore.ts b/src/frontend/src/stores/flowManagerStore.ts
index dc6342338..ee2bd172d 100644
--- a/src/frontend/src/stores/flowManagerStore.ts
+++ b/src/frontend/src/stores/flowManagerStore.ts
@@ -11,7 +11,9 @@ import {
applyEdgeChanges,
applyNodeChanges,
} from "reactflow";
+import ShortUniqueId from "short-unique-id";
import { create } from "zustand";
+const uid = new ShortUniqueId({ length: 5 });
type RFState = {
nodes: Node[];
@@ -27,6 +29,8 @@ type RFState = {
position: { x: number; y: number; paneX?: number; paneY?: number }
) => void;
lastCopiedSelection: { nodes: any; edges: any };
+ nodeId: string;
+ incrementNodeId: () => void;
};
// this is our useStore hook that we can use in our components to get parts of the store and call actions
@@ -63,6 +67,10 @@ const useStore = create((set, get) => ({
},
paste: (selection, position) => {},
lastCopiedSelection: { nodes: [], edges: [] },
+ nodeId: uid(),
+ incrementNodeId: () => {
+ set((state) => ({ nodeId: uid() }));
+ },
}));
export default useStore;
diff --git a/src/frontend/src/types/tabs/index.ts b/src/frontend/src/types/tabs/index.ts
index 9f9bb87ba..0e03e6b73 100644
--- a/src/frontend/src/types/tabs/index.ts
+++ b/src/frontend/src/types/tabs/index.ts
@@ -40,7 +40,6 @@ export type FlowsContextType = {
isComponent?: boolean;
position?: XYPosition;
}) => Promise;
- hardReset: () => void;
getNodeId: (nodeType: string) => string;
isPending: boolean;
setPending: (pending: boolean) => void;