mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-05 15:58:19 +00:00
Route Journal recovery notices through the existing logger
This commit is contained in:
1 parent
9e564eb51e
commit
a0f1483891
2 files changed
+24
-15
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import { EVENT_REQUEST_PERFORM_GC_V3, eventHub } from "@/common/events.ts";
|
||||
import { $msg } from "@/common/translation";
|
||||
import { Notice } from "@/deps.ts";
|
||||
import {
|
||||
createCoreSettingsAfterFullReset,
|
||||
createEditingSettingsAfterFullReset,
|
||||
@@ -171,19 +170,21 @@ export function paneMaintenance(
|
||||
.onClick(async () => {
|
||||
const replicator = this.core.replicator;
|
||||
if (!isLiveSyncJournalReplicator(replicator)) {
|
||||
new Notice(
|
||||
Logger(
|
||||
$msg(
|
||||
"No stopped Journal is available. Retry replication to identify the stopped Journal."
|
||||
)
|
||||
),
|
||||
LOG_LEVEL_NOTICE
|
||||
);
|
||||
return;
|
||||
}
|
||||
const stoppedJournal: Readonly<StoppedJournal> | undefined = replicator.getStoppedJournal();
|
||||
if (!stoppedJournal) {
|
||||
new Notice(
|
||||
Logger(
|
||||
$msg(
|
||||
"No stopped Journal is available. Retry replication to identify the stopped Journal."
|
||||
)
|
||||
),
|
||||
LOG_LEVEL_NOTICE
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -202,10 +203,11 @@ export function paneMaintenance(
|
||||
return;
|
||||
}
|
||||
if (this.core.replicator !== replicator) {
|
||||
new Notice(
|
||||
Logger(
|
||||
$msg(
|
||||
"The active replicator changed. Retry replication to identify the stopped Journal."
|
||||
)
|
||||
),
|
||||
LOG_LEVEL_NOTICE
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -214,10 +216,11 @@ export function paneMaintenance(
|
||||
stoppedJournal
|
||||
);
|
||||
if (!resumed) {
|
||||
new Notice(
|
||||
Logger(
|
||||
$msg(
|
||||
"Journal receipt did not complete after this action. Check the current failure before retrying."
|
||||
)
|
||||
),
|
||||
LOG_LEVEL_NOTICE
|
||||
);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -326,9 +326,11 @@ describe("paneMaintenance", () => {
|
||||
expect(getStoppedJournal).toHaveBeenCalledOnce();
|
||||
expect(rendered.askYesNoDialog).not.toHaveBeenCalled();
|
||||
expect(skipStoppedJournalAndResume).not.toHaveBeenCalled();
|
||||
expect(maintenanceHarness.notice).toHaveBeenCalledWith(
|
||||
"No stopped Journal is available. Retry replication to identify the stopped Journal."
|
||||
expect(maintenanceHarness.logger).toHaveBeenCalledWith(
|
||||
"No stopped Journal is available. Retry replication to identify the stopped Journal.",
|
||||
"notice"
|
||||
);
|
||||
expect(maintenanceHarness.notice).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not skip the stopped Journal when confirmation is cancelled", async () => {
|
||||
@@ -378,9 +380,11 @@ describe("paneMaintenance", () => {
|
||||
|
||||
expect(active.skipStoppedJournalAndResume).not.toHaveBeenCalled();
|
||||
expect(replacement.skipStoppedJournalAndResume).not.toHaveBeenCalled();
|
||||
expect(maintenanceHarness.notice).toHaveBeenCalledWith(
|
||||
"The active replicator changed. Retry replication to identify the stopped Journal."
|
||||
expect(maintenanceHarness.logger).toHaveBeenCalledWith(
|
||||
"The active replicator changed. Retry replication to identify the stopped Journal.",
|
||||
"notice"
|
||||
);
|
||||
expect(maintenanceHarness.notice).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("reports when receipt does not complete after skip and resume", async () => {
|
||||
@@ -391,8 +395,10 @@ describe("paneMaintenance", () => {
|
||||
await rendered.click();
|
||||
|
||||
expect(skipStoppedJournalAndResume).toHaveBeenCalledOnce();
|
||||
expect(maintenanceHarness.notice).toHaveBeenCalledWith(
|
||||
"Journal receipt did not complete after this action. Check the current failure before retrying."
|
||||
expect(maintenanceHarness.logger).toHaveBeenCalledWith(
|
||||
"Journal receipt did not complete after this action. Check the current failure before retrying.",
|
||||
"notice"
|
||||
);
|
||||
expect(maintenanceHarness.notice).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user