feat: add keep alive

This commit is contained in:
2026-07-26 17:56:25 +02:00
parent a157b5f198
commit 31f645ebb2
21 changed files with 1207 additions and 263 deletions

View File

@ -6,6 +6,8 @@ import ConnectionPanel from '../../components/dsp408/ConnectionSection/Connectio
import GainSection from '../../components/dsp408/GainSection/GainSection';
import { NotificationType } from '../../types/types';
import './DspPage.css';
import GateSection from '../../components/dsp408/GateSection/GateSection';
import { invoke } from '@tauri-apps/api/core';
function DSPPage({
dsp,
@ -129,6 +131,41 @@ function DSPPage({
},
];
const presets = dsp.state?.presets.names?.map((name, index) => ({
id: index === 0 ? 'f00' : `u${String(index).padStart(2, '0')}`,
name,
})) ?? [
{
id: 'f00',
name: 'Factory Preset',
},
...Array.from({ length: 20 }, (_, index) => ({
id: `u${String(index + 1).padStart(2, '0')}`,
name: 'Default Preset',
})),
];
const selectedPreset = dsp.state?.presets.current_index ?? 0;
const recallPreset = async (presetIndex: number) => {
try {
const success = await invoke<boolean>('recall_preset', {
id: dsp.id,
presetIndex,
});
if (success) {
notify(`Preset ${presetIndex} recalled`, 'success', dsp.name);
} else {
notify('Failed to recall preset', 'error', dsp.name);
}
return success;
} catch (err) {
notify(`Preset recall failed: ${String(err)}`, 'error', dsp.name);
return false;
}
};
const renderTab = () => {
switch (activeSidebar) {
case 'overview':
@ -137,6 +174,9 @@ function DSPPage({
case 'gain':
return <GainSection dsp={dsp} notify={notify} />;
case 'gate':
return <GateSection dsp={dsp} notify={notify} />;
default:
return null;
}
@ -149,6 +189,15 @@ function DSPPage({
activeId={activeSidebar}
onSelect={setActiveSidebar}
appName={dsp.name}
appOptions={presets}
selectedAppId={presets[selectedPreset]?.id}
onAppChange={(id) => {
const presetIndex = presets.findIndex((preset) => preset.id === id);
if (presetIndex !== -1) {
recallPreset(presetIndex);
}
}}
expanded={sidebarExpanded}
onToggle={() => setSidebarExpanded((v) => !v)}
/>