diff --git a/src/PiPedalModel.cpp b/src/PiPedalModel.cpp index 79fd030..8ef5fd7 100644 --- a/src/PiPedalModel.cpp +++ b/src/PiPedalModel.cpp @@ -729,7 +729,12 @@ void PiPedalModel::SetSnapshot(int64_t selectedSnapshot) } } pedalboardChanged = true; + } else if (selectedSnapshot == -1) + { + this->pedalboard.selectedSnapshot(-1); + pedalboardChanged = true; } + } if (pedalboardChanged) { @@ -3505,6 +3510,10 @@ void PiPedalModel::SetChannelRouterSettings(int64_t clientId, ChannelRouterSetti } std::string PiPedalModel::Tone3000ThumbnailDirectory() +{ + return "/var/pipedal/audio_uploads/tone3000_thumbnails"; +} +std::string PiPedalModel::OldTone3000ThumbnailDirectory() { return "/var/pipedal/tone3000_thumbnails"; } diff --git a/src/PiPedalModel.hpp b/src/PiPedalModel.hpp index 2e14f5f..3f6d42b 100644 --- a/src/PiPedalModel.hpp +++ b/src/PiPedalModel.hpp @@ -303,6 +303,7 @@ namespace pipedal Storage &GetStorage() { return storage; } virtual std::string Tone3000ThumbnailDirectory() override; + virtual std::string OldTone3000ThumbnailDirectory() override; bool GetHasWifi(); diff --git a/vite/src/pipedal/PiPedalModel.tsx b/vite/src/pipedal/PiPedalModel.tsx index 6077a36..40f38ce 100644 --- a/vite/src/pipedal/PiPedalModel.tsx +++ b/vite/src/pipedal/PiPedalModel.tsx @@ -1802,9 +1802,7 @@ export class PiPedalModel //implements PiPedalModel setSnapshots(snapshots: (Snapshot | null)[], selectedSnapshot: number) { let pedalboard = this.pedalboard.get().clone(); pedalboard.snapshots = snapshots; - if (selectedSnapshot !== -1) { - pedalboard.selectedSnapshot = selectedSnapshot; - } + pedalboard.selectedSnapshot = selectedSnapshot; this.pruneSnapshotValues(pedalboard); this.setModelPedalboard(pedalboard); diff --git a/vite/src/pipedal/SnapshotButton.tsx b/vite/src/pipedal/SnapshotButton.tsx index 7844fc9..a215eb2 100644 --- a/vite/src/pipedal/SnapshotButton.tsx +++ b/vite/src/pipedal/SnapshotButton.tsx @@ -150,7 +150,8 @@ export default class SnapshotButton extends ResizeResponsiveComponent { if (snapshot) this.props.onSelectSnapshot(snapshotIndex); }} + onClick={() => { + if (snapshot) this.props.onSelectSnapshot(snapshotIndex); }} > {/* select background mask*/}
{this.onEditSnapshot(index)}} - onSaveSnapshot={(index)=>{ this.onSaveSnapshot(index); }} - onSelectSnapshot={(index)=>{this.model.selectSnapshot(index);}} + onEditSnapshot={(index) => { this.onEditSnapshot(index) }} + onSaveSnapshot={(index) => { this.onSaveSnapshot(index); }} + onSelectSnapshot={(index) => { this.model.selectSnapshot(index); }} /> ); } - + handleRemoveSnapshot(snapshotId: number) { + let snapshots = Snapshot.cloneSnapshots(this.state.snapshots); + snapshots[snapshotId] = null; + this.setState({ + snapshots: snapshots, + snapshotPropertiesDialogOpen: false, + selectedSnapshot: -1 + }); + this.model.setSnapshots(snapshots, -1); + this.model.selectSnapshot(-1); + } handleSnapshotPropertyOk(index: number, name: string, color: string, editing: boolean) { if (editing) { @@ -286,6 +295,9 @@ export default class SnapshotPanel extends ResizeResponsiveComponent { + this.handleRemoveSnapshot(snapshotId); + }} onClose={() => { this.setState({ snapshotPropertiesDialogOpen: false }); }} onOk={(snapshotId, name, color, editing) => { this.handleSnapshotPropertyOk(snapshotId, name, color, editing); diff --git a/vite/src/pipedal/SnapshotPropertiesDialog.tsx b/vite/src/pipedal/SnapshotPropertiesDialog.tsx index c69128a..c955866 100644 --- a/vite/src/pipedal/SnapshotPropertiesDialog.tsx +++ b/vite/src/pipedal/SnapshotPropertiesDialog.tsx @@ -36,7 +36,7 @@ import { colorKeys } from "./MaterialColors"; import ResizeResponsiveComponent from './ResizeResponsiveComponent'; import ColorDropdownButton, { DropdownAlignment } from './ColorDropdownButton'; -const snapshotColors = colorKeys.slice(0,100); +const snapshotColors = colorKeys.slice(0, 100); const NBSP = "\u00A0"; export interface SnapshotPropertiesDialogProps { @@ -46,6 +46,7 @@ export interface SnapshotPropertiesDialogProps { snapshotIndex: number, color: string, onOk: (snapshotId: number, name: string, color: string, editing: boolean) => void, + onRemove: (snapshotid: number) => void, onClose: () => void }; @@ -54,6 +55,7 @@ export interface SnapshotPropertiesDialogState { color: string, nameErrorMessage: string, compactVertical: boolean, + showRemoveConfirm: boolean }; export default class SnapshotPropertiesDialog extends ResizeResponsiveComponent { @@ -72,21 +74,21 @@ export default class SnapshotPropertiesDialog extends ResizeResponsiveComponent< color = snapshotColors[0]; } let name = this.props.name; - if (name.length === 0 && !this.props.editing) - { - name = "Snapshot " + (this.props.snapshotIndex+1); + if (name.length === 0 && !this.props.editing) { + name = "Snapshot " + (this.props.snapshotIndex + 1); } return { name: name, color: color, nameErrorMessage: "", - compactVertical: this.getCompactVertical() + compactVertical: this.getCompactVertical(), + showRemoveConfirm: false }; } onWindowSizeChanged(width: number, height: number): void { - super.onWindowSizeChanged(width,height); - this.setState({compactVertical: this.getCompactVertical() }) + super.onWindowSizeChanged(width, height); + this.setState({ compactVertical: this.getCompactVertical() }) } handleOk() { @@ -102,6 +104,10 @@ export default class SnapshotPropertiesDialog extends ResizeResponsiveComponent< } } + handleRemoveSnapshot() { + this.props.onRemove(this.props.snapshotIndex); + } + render() { let props = this.props; @@ -111,9 +117,9 @@ export default class SnapshotPropertiesDialog extends ResizeResponsiveComponent< let okButtonText = this.props.editing ? "OK" : "Save"; return ( - { this.handleOk(); }} + onEnterKey={() => { this.handleOk(); }} >
@@ -127,7 +133,7 @@ export default class SnapshotPropertiesDialog extends ResizeResponsiveComponent<
- + Color { - this.setState({color: newcolor}); - }} /> - + onColorChange={(newcolor) => { + this.setState({ color: newcolor }); + }} /> + + +
- - + { + this.setState({ showRemoveConfirm: false }); + this.handleRemoveSnapshot(); + }} + onClose={() => { this.setState({ showRemoveConfirm: false }); }} > + + Are you sure you want to remove this snapshot? + + + + + + + ); } } \ No newline at end of file