mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-25 05:53:00 +00:00
Refine P2P and manual setup workflows
This commit is contained in:
@@ -23,6 +23,10 @@ export type ConfiguredSettings = {
|
||||
export type CoreReadiness = {
|
||||
databaseReady: boolean;
|
||||
appReady: boolean;
|
||||
configured?: boolean;
|
||||
remoteType?: string;
|
||||
settingVersion?: number;
|
||||
suspended?: boolean;
|
||||
};
|
||||
|
||||
export type ReplicationAttempt = CoreReadiness & {
|
||||
@@ -348,9 +352,14 @@ export async function waitForLiveSyncCoreReady(
|
||||
[
|
||||
"(async()=>{",
|
||||
"const core=app.plugins.plugins['obsidian-livesync'].core;",
|
||||
"const settings=core.services.setting.currentSettings();",
|
||||
"return JSON.stringify({",
|
||||
"databaseReady:core.services.database.isDatabaseReady(),",
|
||||
"appReady:core.services.appLifecycle.isReady(),",
|
||||
"configured:settings?.isConfigured===true,",
|
||||
"remoteType:settings?.remoteType??'',",
|
||||
"settingVersion:settings?.settingVersion,",
|
||||
"suspended:core.services.appLifecycle.isSuspended(),",
|
||||
"});",
|
||||
"})()",
|
||||
].join(""),
|
||||
|
||||
@@ -177,16 +177,34 @@ export async function captureAndStartInitialisation(
|
||||
captures: SetupCaptureNames
|
||||
): Promise<string> {
|
||||
const p2pFirstDevice = mode === "new" && captures.guide === "p2p-setup";
|
||||
const p2pAdditionalDevice = mode === "existing" && captures.guide === "p2p-setup";
|
||||
const title = p2pFirstDevice
|
||||
? "Setup Complete: Preparing This P2P Device"
|
||||
: p2pAdditionalDevice
|
||||
? "Setup Complete: Preparing to Fetch from Another Device"
|
||||
: mode === "new"
|
||||
? "Setup Complete: Preparing to Initialise Server"
|
||||
: "Setup Complete: Preparing to Fetch Synchronisation Data";
|
||||
const button = p2pFirstDevice
|
||||
? "Restart and Prepare This Device"
|
||||
: p2pAdditionalDevice
|
||||
? "Restart and Select Source Device"
|
||||
: mode === "new"
|
||||
? "Restart and Initialise Server"
|
||||
: "Restart and Fetch Data";
|
||||
if (p2pAdditionalDevice) {
|
||||
await withObsidianPage(port, async (page) => {
|
||||
const modal = modalByTitle(page, title);
|
||||
await modal
|
||||
.getByText("After restarting, select an online source device for the initial Fetch.", {
|
||||
exact: false,
|
||||
})
|
||||
.waitFor({ state: "visible", timeout: uiTimeoutMs });
|
||||
if ((await modal.getByText("downloaded from the server", { exact: false }).count()) !== 0) {
|
||||
throw new Error("P2P additional-device setup still describes the initial Fetch as a server download.");
|
||||
}
|
||||
});
|
||||
}
|
||||
const screenshot = await captureGuideDialogue(
|
||||
port,
|
||||
`guide-${captures.guide}-${mode === "new" ? "first-initialise" : "second-fetch"}.png`,
|
||||
|
||||
Reference in New Issue
Block a user