| import { ReactNode, useEffect, useRef } from "react"; | |
| interface FlowPreservationProviderProps { | |
| children: ReactNode; | |
| } | |
| export function FlowPreservationProvider({ children }: FlowPreservationProviderProps) { | |
| const isFirstRender = useRef(true); | |
| useEffect(() => { | |
| if (isFirstRender.current) { | |
| isFirstRender.current = false; | |
| // Restore any saved flow state from localStorage if needed | |
| const savedFlow = localStorage.getItem("flow_state"); | |
| if (savedFlow) { | |
| try { | |
| const parsed = JSON.parse(savedFlow); | |
| // Dispatch event to restore workspace panels | |
| window.dispatchEvent(new CustomEvent("flow:restore", { detail: parsed })); | |
| } catch (e) { | |
| console.warn("Failed to restore flow state", e); | |
| } | |
| } | |
| } | |
| }, []); | |
| useEffect(() => { | |
| const handleSave = () => { | |
| // Example: save workspace panels layout | |
| const panels = document.querySelectorAll('[data-flow-id]'); | |
| // Simplified – you would collect actual panel data | |
| }; | |
| window.addEventListener("beforeunload", handleSave); | |
| return () => window.removeEventListener("beforeunload", handleSave); | |
| }, []); | |
| return <>{children}</>; | |
| } |
Xet Storage Details
- Size:
- 1.21 kB
- Xet hash:
- 72fd0470704a345bf95b0cf0227ff31c4d8d5760a70ad16337e5abb84db07713
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.