protect against localstrorage error

This commit is contained in:
arkml 2025-09-08 14:07:39 +05:30
parent f772088e90
commit 9a60a03217
2 changed files with 9 additions and 4 deletions

View file

@ -1004,23 +1004,27 @@ export function WorkflowEditor({
const [isEditingProjectName, setIsEditingProjectName] = useState<boolean>(false); const [isEditingProjectName, setIsEditingProjectName] = useState<boolean>(false);
const [pendingProjectName, setPendingProjectName] = useState<string | null>(null); const [pendingProjectName, setPendingProjectName] = useState<string | null>(null);
// Build progress tracking - persists once set to true // Build progress tracking - persists once set to true (guard SSR)
const [hasAgentInstructionChanges, setHasAgentInstructionChanges] = useState<boolean>(() => { const [hasAgentInstructionChanges, setHasAgentInstructionChanges] = useState<boolean>(() => {
if (typeof window === 'undefined') return false;
return localStorage.getItem(`agent_instructions_changed_${projectId}`) === 'true'; return localStorage.getItem(`agent_instructions_changed_${projectId}`) === 'true';
}); });
// Test progress tracking - persists once set to true // Test progress tracking - persists once set to true (guard SSR)
const [hasPlaygroundTested, setHasPlaygroundTested] = useState<boolean>(() => { const [hasPlaygroundTested, setHasPlaygroundTested] = useState<boolean>(() => {
if (typeof window === 'undefined') return false;
return localStorage.getItem(`playground_tested_${projectId}`) === 'true'; return localStorage.getItem(`playground_tested_${projectId}`) === 'true';
}); });
// Publish progress tracking - persists once set to true // Publish progress tracking - persists once set to true (guard SSR)
const [hasPublished, setHasPublished] = useState<boolean>(() => { const [hasPublished, setHasPublished] = useState<boolean>(() => {
if (typeof window === 'undefined') return false;
return localStorage.getItem(`has_published_${projectId}`) === 'true'; return localStorage.getItem(`has_published_${projectId}`) === 'true';
}); });
// Use progress tracking - persists once set to true // Use progress tracking - persists once set to true (guard SSR)
const [hasClickedUse, setHasClickedUse] = useState<boolean>(() => { const [hasClickedUse, setHasClickedUse] = useState<boolean>(() => {
if (typeof window === 'undefined') return false;
return localStorage.getItem(`has_clicked_use_${projectId}`) === 'true'; return localStorage.getItem(`has_clicked_use_${projectId}`) === 'true';
}); });

View file

@ -1,3 +1,4 @@
"use client";
import { useFloating, offset, flip, shift, arrow, FloatingArrow, FloatingPortal, autoUpdate } from '@floating-ui/react'; import { useFloating, offset, flip, shift, arrow, FloatingArrow, FloatingPortal, autoUpdate } from '@floating-ui/react';
import { useCallback, useEffect, useRef, useState } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react';
import { XIcon } from 'lucide-react'; import { XIcon } from 'lucide-react';