feat: disable localStorage persistence and add auto-load last project
**useMultiTrack.ts:** - Removed localStorage persistence (tracks, effects, automation) - Now relies entirely on IndexedDB via project management system - Simpler state management without dual persistence **AudioEditor.tsx:** - Store last project ID in localStorage when saving - Auto-load last project on page mount - Only runs once per session with hasAutoLoaded flag - Falls back to empty state if project can't be loaded **Benefits:** - No more conflicts between localStorage and IndexedDB - Effects and automation properly persisted - Seamless experience - reload page and your project is ready - Single source of truth (IndexedDB) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -911,6 +911,9 @@ export function AudioEditor() {
|
||||
|
||||
setCurrentProjectId(projectId);
|
||||
|
||||
// Save last project ID to localStorage for auto-load on next visit
|
||||
localStorage.setItem('audio-ui-last-project', projectId);
|
||||
|
||||
addToast({
|
||||
title: 'Project Saved',
|
||||
description: `"${currentProjectName}" saved successfully`,
|
||||
@@ -1009,6 +1012,29 @@ export function AudioEditor() {
|
||||
}
|
||||
}, [loadTracks, addToast]);
|
||||
|
||||
// Auto-load last project on mount
|
||||
const [hasAutoLoaded, setHasAutoLoaded] = React.useState(false);
|
||||
React.useEffect(() => {
|
||||
if (hasAutoLoaded) return; // Only run once
|
||||
|
||||
const loadLastProject = async () => {
|
||||
const lastProjectId = localStorage.getItem('audio-ui-last-project');
|
||||
if (lastProjectId) {
|
||||
try {
|
||||
console.log('[Auto-load] Loading last project:', lastProjectId);
|
||||
await handleLoadProject(lastProjectId);
|
||||
} catch (error) {
|
||||
console.error('[Auto-load] Failed to load last project:', error);
|
||||
// Clear invalid project ID
|
||||
localStorage.removeItem('audio-ui-last-project');
|
||||
}
|
||||
}
|
||||
setHasAutoLoaded(true);
|
||||
};
|
||||
|
||||
loadLastProject();
|
||||
}, [hasAutoLoaded, handleLoadProject]);
|
||||
|
||||
// Delete project
|
||||
const handleDeleteProject = React.useCallback(async (projectId: string) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user