fix: migrate existing tracks to new 180px height from localStorage
Added migration logic to useMultiTrack hook: - When loading tracks from localStorage, check if height < DEFAULT_TRACK_HEIGHT - Automatically upgrade old heights (120px, 150px) to new default (180px) - Preserves custom heights that are already >= 180px This fixes the inline style issue where existing tracks had style="height: 120px" that was cutting off the level meter. After this update, refreshing the page will automatically upgrade all existing tracks to the new height without losing any data. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { useState, useCallback, useEffect } from 'react';
|
||||
import type { Track } from '@/types/track';
|
||||
import { createTrack, createTrackFromBuffer } from '@/lib/audio/track-utils';
|
||||
import { createEffectChain } from '@/lib/audio/effects/chain';
|
||||
import { DEFAULT_TRACK_HEIGHT } from '@/types/track';
|
||||
|
||||
const STORAGE_KEY = 'audio-ui-multi-track';
|
||||
|
||||
@@ -29,6 +30,7 @@ export function useMultiTrack() {
|
||||
return parsed.map((t: any) => ({
|
||||
...t,
|
||||
name: String(t.name || 'Untitled Track'), // Ensure name is always a string
|
||||
height: t.height && t.height >= DEFAULT_TRACK_HEIGHT ? t.height : DEFAULT_TRACK_HEIGHT, // Migrate old heights
|
||||
audioBuffer: null, // Will need to be reloaded
|
||||
effectChain: t.effectChain || createEffectChain(`${t.name} Effects`), // Restore effect chain or create new
|
||||
selection: t.selection || null, // Initialize selection
|
||||
|
||||
Reference in New Issue
Block a user