Confirmation before Wipe Disc or Delete Track

Resolves #14
This commit is contained in:
Stefano Brilli 2020-09-02 20:38:54 +02:00
parent 2bd1498af0
commit 1b79416d2a
2 changed files with 15 additions and 1 deletions

View File

@ -78,6 +78,12 @@ export function renameDisc({ newName }: { newName: string }) {
export function deleteTracks(indexes: number[]) {
return async function(dispatch: AppDispatch) {
const confirmation = window.confirm(
`Proceed with Delete Track${indexes.length !== 1 ? 's' : ''}? This operation cannot be undone.`
);
if (!confirmation) {
return;
}
const { netmdService } = serviceRegistry;
dispatch(appStateActions.setLoading(true));
indexes = indexes.sort();
@ -91,6 +97,10 @@ export function deleteTracks(indexes: number[]) {
export function wipeDisc() {
return async function(dispatch: AppDispatch) {
const confirmation = window.confirm(`Proceed with Wipe Disc? This operation cannot be undone.`);
if (!confirmation) {
return;
}
const { netmdService } = serviceRegistry;
dispatch(appStateActions.setLoading(true));
await netmdService!.wipeDisc();

View File

@ -1,4 +1,4 @@
import { Disc, Track, Encoding, Wireformat, TrackFlag } from 'netmd-js';
import { Channels, Track, Encoding, Wireformat, TrackFlag } from 'netmd-js';
import { NetMDService } from './netmd';
import { sleep, sanitizeTitle } from '../utils';
import { assert } from 'netmd-js/dist/utils';
@ -13,6 +13,7 @@ class NetMDMockService implements NetMDService {
// duration: 5 * 60 * 512,
// encoding: Encoding.sp,
// index: 0,
// channel: Channels.stereo,
// protected: TrackFlag.unprotected,
// title: 'Mock Track 1',
// },
@ -20,6 +21,7 @@ class NetMDMockService implements NetMDService {
// duration: 5 * 60 * 512,
// encoding: Encoding.sp,
// index: 1,
// channel: Channels.stereo,
// protected: TrackFlag.unprotected,
// title: 'Mock Track 2',
// },
@ -27,6 +29,7 @@ class NetMDMockService implements NetMDService {
// duration: 5 * 60 * 512,
// encoding: Encoding.sp,
// index: 2,
// channel: Channels.stereo,
// protected: TrackFlag.unprotected,
// title: 'Mock Track 3',
// },
@ -34,6 +37,7 @@ class NetMDMockService implements NetMDService {
// duration: 5 * 60 * 512,
// encoding: Encoding.sp,
// index: 3,
// channel: Channels.stereo,
// protected: TrackFlag.unprotected,
// title: 'Mock Track 4',
// },