mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-31 08:51:23 +00:00
Refine P2P and manual setup workflows
This commit is contained in:
@@ -128,12 +128,18 @@ export class ObsidianConfirm<T extends ObsidianServiceContext = ObsidianServiceC
|
||||
opt: { title?: string; defaultAction: T[number]; timeout?: number }
|
||||
): Promise<T[number] | false> {
|
||||
const defaultTitle = $msg("moduleInputUIObsidian.defaultTitleSelect");
|
||||
// Commonlib owns the transport decision, while LiveSync owns the
|
||||
// concrete Obsidian view which lets users revise that decision.
|
||||
const presentedMessage =
|
||||
opt.title === "P2P Connection Request"
|
||||
? message.replace("Peer-to-Peer Replicator Pane", $msg("P2P Status pane"))
|
||||
: message;
|
||||
if (!this.hasCountdown(opt.timeout)) {
|
||||
const result = await confirmAction(
|
||||
this._app,
|
||||
{
|
||||
title: opt.title || defaultTitle,
|
||||
message,
|
||||
message: presentedMessage,
|
||||
actions: buttons,
|
||||
actionLayout: "vertical",
|
||||
defaultAction: opt.defaultAction,
|
||||
@@ -146,7 +152,7 @@ export class ObsidianConfirm<T extends ObsidianServiceContext = ObsidianServiceC
|
||||
return confirmWithMessageWithWideButton(
|
||||
this._plugin,
|
||||
opt.title || defaultTitle,
|
||||
message,
|
||||
presentedMessage,
|
||||
buttons,
|
||||
opt.defaultAction,
|
||||
opt.timeout
|
||||
|
||||
@@ -214,6 +214,31 @@ describe("ObsidianConfirm Fancy Kit adapter", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("refers P2P connection approvals to the current P2P Status pane", async () => {
|
||||
const { confirm, plugin } = createConfirm();
|
||||
const actions = ["Accept", "Ignore"] as const;
|
||||
mocks.legacyWideConfirm.mockResolvedValueOnce("Ignore");
|
||||
|
||||
await confirm.askSelectStringDialogue(
|
||||
"You can revoke your decision from the Peer-to-Peer Replicator Pane.",
|
||||
actions,
|
||||
{
|
||||
title: "P2P Connection Request",
|
||||
defaultAction: "Ignore",
|
||||
timeout: 30,
|
||||
}
|
||||
);
|
||||
|
||||
expect(mocks.legacyWideConfirm).toHaveBeenCalledWith(
|
||||
plugin,
|
||||
"P2P Connection Request",
|
||||
"You can revoke your decision from the P2P Status pane.",
|
||||
actions,
|
||||
"Ignore",
|
||||
30
|
||||
);
|
||||
});
|
||||
|
||||
it("dismisses an open Kit dialogue when the plug-in unload event is emitted", async () => {
|
||||
const { confirm, events } = createConfirm();
|
||||
let observedSignal: AbortSignal | undefined;
|
||||
|
||||
Reference in New Issue
Block a user