mirror of
https://github.com/jhbruhn/respira.git
synced 2026-01-27 10:23:41 +00:00
Fix pattern re-upload after deletion by preserving filename
Fix bug where deleting a cached pattern prevented re-uploading because the filename was lost. After deletion, the pattern remains visible in the UI for re-editing and re-uploading, but the upload would silently fail because displayFileName was empty. The issue occurred because: 1. Pattern loaded from cache uses resumeFileName (from hook) 2. Local fileName state in FileUpload was never set (empty string) 3. After deletion, resumeFileName is cleared to null 4. displayFileName becomes empty, preventing upload Solution: - Add fallback to 'pattern.pes' when pesDataProp exists but no filename - This ensures re-upload works after deletion while keeping pattern visible - Pattern data (pesData) persists in App.tsx state for re-editing Now users can delete a cached pattern and immediately re-upload it with position adjustments or other modifications. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3d51992581
commit
085ac1a5f7
2 changed files with 3 additions and 1 deletions
|
|
@ -39,7 +39,8 @@ export function FileUpload({
|
||||||
|
|
||||||
// Use prop pesData if available (from cached pattern), otherwise use local state
|
// Use prop pesData if available (from cached pattern), otherwise use local state
|
||||||
const pesData = pesDataProp || localPesData;
|
const pesData = pesDataProp || localPesData;
|
||||||
const displayFileName = resumeFileName || fileName;
|
// When resumeFileName is cleared but we still have pesData, preserve the filename
|
||||||
|
const displayFileName = resumeFileName || fileName || (pesDataProp ? 'pattern.pes' : '');
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const handleFileChange = useCallback(
|
const handleFileChange = useCallback(
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,7 @@ export function useBrotherMachine() {
|
||||||
setResumeFileName(null);
|
setResumeFileName(null);
|
||||||
// NOTE: We intentionally DON'T clear setResumedPattern(null)
|
// NOTE: We intentionally DON'T clear setResumedPattern(null)
|
||||||
// so the pattern remains visible in the canvas for re-editing
|
// so the pattern remains visible in the canvas for re-editing
|
||||||
|
// However, we DO need to preserve pesData in App.tsx for re-upload
|
||||||
|
|
||||||
await refreshStatus();
|
await refreshStatus();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue