diff --git a/src/LiveSyncBaseCore.ts b/src/LiveSyncBaseCore.ts index 76f06006..27df933d 100644 --- a/src/LiveSyncBaseCore.ts +++ b/src/LiveSyncBaseCore.ts @@ -41,6 +41,7 @@ import { supportedOpenReplicationContinuous, supportedOpenReplicationOneShot, supportedOpenReplicationUnattended, + supportedStopActiveTransfer, } from "@vrtmrz/livesync-commonlib/replication"; import { LiveSyncCouchDBReplicator } from "@vrtmrz/livesync-commonlib/compat/replication/couchdb/LiveSyncReplicator"; import { LiveSyncJournalReplicator } from "@vrtmrz/livesync-commonlib/compat/replication/journal/LiveSyncJournalReplicator"; @@ -165,6 +166,7 @@ export class LiveSyncBaseCore< userInitiatedOneShot: supportedOpenReplicationOneShot(), unattendedOneShot: supportedOpenReplicationUnattended(), continuous: supportedOpenReplicationContinuous(), + stopActiveTransfer: supportedStopActiveTransfer(), }, [REMOTE_MINIO]: { kind: REMOTE_MINIO, @@ -175,6 +177,7 @@ export class LiveSyncBaseCore< userInitiatedOneShot: supportedOpenReplicationOneShot(), unattendedOneShot: supportedOpenReplicationUnattended(), continuous: CAPABILITY_NOT_APPLICABLE, + stopActiveTransfer: supportedStopActiveTransfer(), }, }); this.services.replicator.registerReplicatorProviderDefinitions(definitions); diff --git a/src/modules/essential/ModuleBasicMenu.ts b/src/modules/essential/ModuleBasicMenu.ts index 5bedf7b6..7bab5ef9 100644 --- a/src/modules/essential/ModuleBasicMenu.ts +++ b/src/modules/essential/ModuleBasicMenu.ts @@ -89,7 +89,7 @@ export class ModuleBasicMenu extends AbstractModule { checkCallback: (checking) => { if (!this.settings.useAdvancedMode) return false; if (!checking) { - this.core.replicator.terminateSync(); + fireAndForget(() => this.services.replication.stopActiveTransfer()); } return true; }, diff --git a/src/modules/essential/ModuleBasicMenu.unit.spec.ts b/src/modules/essential/ModuleBasicMenu.unit.spec.ts index 7f670aa0..e0c13bbf 100644 --- a/src/modules/essential/ModuleBasicMenu.unit.spec.ts +++ b/src/modules/essential/ModuleBasicMenu.unit.spec.ts @@ -26,6 +26,7 @@ function createFixture() { }, replication: { replicateUserInitiated: vi.fn(async () => ({ status: "completed" as const })), + stopActiveTransfer: vi.fn(async () => ({ status: "completed" as const })), }, vault: { getActiveFilePath: vi.fn((): string | null => "note.md"), @@ -136,6 +137,19 @@ describe("ModuleBasicMenu command palette", () => { expect(fixture.getCommand("livesync-abortsync").checkCallback?.(true)).toBe(true); }); + it("routes an explicit stop through the active provider capability", async () => { + const fixture = createFixture(); + fixture.settings.useAdvancedMode = true; + + await fixture.module._everyOnloadStart(); + + expect(fixture.getCommand("livesync-abortsync").checkCallback?.(false)).toBe(true); + await vi.waitFor(() => { + expect(fixture.services.replication.stopActiveTransfer).toHaveBeenCalledOnce(); + }); + expect(fixture.core.replicator.terminateSync).not.toHaveBeenCalled(); + }); + it("keeps active-file database information available and opens it in a copy dialogue", async () => { const fixture = createFixture();