Route replication through provider capabilities

This commit is contained in:
vorotamoroz
2026-08-27 11:16:30 +00:00
parent 7aa41baf08
commit 56444bb98b
23 changed files with 918 additions and 205 deletions
+5 -1
View File
@@ -4,6 +4,7 @@ import { fireAndForget } from "octagonal-wheels/promises";
import { AbstractModule } from "@/modules/AbstractModule";
import { $msg } from "@/common/translation";
import { copyFileDatabaseInfo } from "@/serviceFeatures/fileDatabaseInfo";
import { USER_INITIATED_REPLICATION_AUTHORITY } from "@vrtmrz/livesync-commonlib/replication";
// Separated Module for basic menu commands, which are not related to obsidian specific features. It is expected to be used in other platforms with minimal changes.
// However, it is odd that it has here at all; it really ought to be in each respective feature. It will likely be moved eventually. Until now, addCommand pointed to Obsidian's version.
export class ModuleBasicMenu extends AbstractModule {
@@ -12,7 +13,10 @@ export class ModuleBasicMenu extends AbstractModule {
id: "livesync-replicate",
name: $msg("Sync now"),
callback: async () => {
await this.services.replication.replicate();
await this.services.replication.replicateUserInitiated({
trigger: "manual",
interaction: USER_INITIATED_REPLICATION_AUTHORITY,
});
},
});
this.addCommand({
@@ -25,7 +25,7 @@ function createFixture() {
registerProtocolHandler: vi.fn(),
},
replication: {
replicate: vi.fn(async () => undefined),
replicateUserInitiated: vi.fn(async () => ({ status: "completed" as const })),
},
vault: {
getActiveFilePath: vi.fn((): string | null => "note.md"),