Last active
July 31, 2025 20:14
-
-
Save olawanlejoel/4f0717654f01e99a83575b7459ff2dca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ...existing code... | |
| useEffect(() => { | |
| if (typeof window === 'undefined') return; // Prevent SSR issues | |
| if (hasRestored.current) return; | |
| const activeJobId = localStorage.getItem("spidra-active-job"); | |
| if (activeJobId) { | |
| try { | |
| const parsed = JSON.parse(activeJobId); | |
| if (parsed?.jobId && parsed?.formData) { | |
| setFormData(parsed.formData); | |
| setAiMode(parsed.formData.aiMode ?? false); | |
| setCurrentJobId(parsed.jobId); | |
| setIsLoading(true); | |
| setProgress({ message: "Resuming scrape...", percentage: 0 }); | |
| addToast({ message: "Restored previous job", type: "info" }); | |
| hasRestored.current = true; | |
| } | |
| } catch (err) { | |
| console.error("Failed to parse saved scrape data", err); | |
| localStorage.removeItem("spidra-active-job"); | |
| } | |
| } | |
| }, []); | |
| // ...existing code... | |
| // Add this helper function at the top of the component | |
| const getStoredJobData = () => { | |
| if (typeof window === 'undefined') return null; | |
| try { | |
| const activeJobId = localStorage.getItem("spidra-active-job"); | |
| return activeJobId ? JSON.parse(activeJobId) : null; | |
| } catch { | |
| return null; | |
| } | |
| }; | |
| const setStoredJobData = (data: any) => { | |
| if (typeof window === 'undefined') return; | |
| localStorage.setItem("spidra-active-job", JSON.stringify(data)); | |
| }; | |
| const removeStoredJobData = () => { | |
| if (typeof window === 'undefined') return; | |
| localStorage.removeItem("spidra-active-job"); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment