|
|
@@ -1,7 +1,7 @@
|
|
|
// Moving, copying and swapping pads (build plan M6), shared by drag and drop
|
|
|
// and the "Move to pad" / "Copy to pad" buttons.
|
|
|
import { Service, type Pad } from "./api";
|
|
|
-import { app, confirm, run, ui } from "./store.svelte";
|
|
|
+import { app, confirm, message, run, ui } from "./store.svelte";
|
|
|
import { PER_BANK } from "./slots";
|
|
|
|
|
|
export type Transfer = "move" | "swap" | "copy";
|
|
|
@@ -19,6 +19,14 @@ export function transferKind(from: Pad, to: Pad, copy: boolean): Transfer {
|
|
|
* sample.
|
|
|
*/
|
|
|
export async function transfer(kind: Transfer, from: number, to: number): Promise<void> {
|
|
|
+ try {
|
|
|
+ await doTransfer(kind, from, to);
|
|
|
+ } catch (e) {
|
|
|
+ app.error = message(e);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function doTransfer(kind: Transfer, from: number, to: number): Promise<void> {
|
|
|
const pads = app.state?.pads;
|
|
|
if (!pads || from === to) return;
|
|
|
const src = pads[from];
|