fix: bank display showing 1 instead of 0 + build fixes

- Removed 'e.bank||1' falsy trap (was converting bank 0 to 1)
- Fixed TypeScript errors: cp guard, unused vars, path aliases
- Added base: '/ui/' to vite config for correct asset paths
- Bank persistence already implemented (localStorage pedal-footswitch-bank)
- Rebuilt and deployed to src/web/ui-dist/
This commit is contained in:
2026-06-13 10:18:33 -04:00
parent 82f687323c
commit 575535762c
60 changed files with 116 additions and 13183 deletions
+18 -4
View File
@@ -3,8 +3,8 @@
* to all footswitch components.
*/
import { createContext, useContext, useState, useCallback, type ReactNode } from 'react';
import type { FootswitchMode, ScribbleStripData, PedalState, PedalBlock } from '../types';
import { createContext, useContext, useState, useCallback, useEffect, type ReactNode } from 'react';
import type { FootswitchMode, ScribbleStripData, PedalState, PedalBlock } from './types';
import { apiPost, activatePreset } from "./hooks/usePedalState";
// ── Context Shape ─────────────────────────────────────────────
@@ -198,9 +198,23 @@ export function FootswitchModeProvider({
onToggleBlock,
}: FootswitchModeProviderProps) {
const [mode, setMode] = useState<FootswitchMode>('stomp');
const [currentBankIndex, setCurrentBankIndex] = useState(0);
const [currentBankIndex, setCurrentBankIndex] = useState(() => {
try {
const saved = localStorage.getItem('pedal-footswitch-bank');
return saved !== null ? parseInt(saved, 10) : 0;
} catch {
return 0;
}
});
const [currentPresetIndex, setCurrentPresetIndex] = useState(0);
const [dirty, setDirty] = useState(false);
const [dirty, _setDirty] = useState(false);
// Persist bank index to localStorage
useEffect(() => {
try {
localStorage.setItem('pedal-footswitch-bank', String(currentBankIndex));
} catch { /* quota exceeded or storage disabled */ }
}, [currentBankIndex]);
// Generate scribble data based on mode
let scribbleData: ScribbleStripData[];