From 6eec8117f5ef34d5c05d28deada2268a280e9068 Mon Sep 17 00:00:00 2001 From: vorotamoroz Date: Tue, 24 Feb 2026 07:51:21 +0000 Subject: [PATCH] Refactor: Constantising log-mark --- src/lib | 2 +- src/modules/core/ModuleReplicator.ts | 3 ++- src/modules/essentialObsidian/ModuleObsidianAPI.ts | 3 ++- src/modules/features/ModuleLog.ts | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib b/src/lib index b19f087..1c176da 160000 --- a/src/lib +++ b/src/lib @@ -1 +1 @@ -Subproject commit b19f0875991a74945db089a3600d7d2469df82c0 +Subproject commit 1c176da469c811cf00a7cd5b16946011b942c8a4 diff --git a/src/modules/core/ModuleReplicator.ts b/src/modules/core/ModuleReplicator.ts index 34a6f55..e059b72 100644 --- a/src/modules/core/ModuleReplicator.ts +++ b/src/modules/core/ModuleReplicator.ts @@ -15,6 +15,7 @@ import { ReplicateResultProcessor } from "./ReplicateResultProcessor"; import { UnresolvedErrorManager } from "@lib/services/base/UnresolvedErrorManager"; import { clearHandlers } from "@lib/replication/SyncParamsHandler"; import type { NecessaryServices } from "@/serviceFeatures/types"; +import { MARK_LOG_NETWORK_ERROR } from "@lib/services/lib/logUtils"; function isOnlineAndCanReplicate( errorManager: UnresolvedErrorManager, @@ -46,7 +47,7 @@ async function canReplicateWithPBKDF2( errorManager.clearError(errorMessage); // Showing message is false: that because be shown here. (And it is a fatal error, no way to hide it). // tagged as network error at beginning for error filtering with NetworkWarningStyles - const ensureMessage = "\u{200b}Failed to initialise the encryption key, preventing replication."; + const ensureMessage = `${MARK_LOG_NETWORK_ERROR}Failed to initialise the encryption key, preventing replication.`; const ensureResult = await replicator.ensurePBKDF2Salt(currentSettings, showMessage, true); if (!ensureResult) { errorManager.showError(ensureMessage, showMessage ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO); diff --git a/src/modules/essentialObsidian/ModuleObsidianAPI.ts b/src/modules/essentialObsidian/ModuleObsidianAPI.ts index d19bb1e..49e81a1 100644 --- a/src/modules/essentialObsidian/ModuleObsidianAPI.ts +++ b/src/modules/essentialObsidian/ModuleObsidianAPI.ts @@ -18,6 +18,7 @@ import { PouchDB } from "../../lib/src/pouchdb/pouchdb-browser.ts"; import { AuthorizationHeaderGenerator } from "../../lib/src/replication/httplib.ts"; import type { LiveSyncCore } from "../../main.ts"; import { EVENT_ON_UNRESOLVED_ERROR, eventHub } from "../../common/events.ts"; +import { MARK_LOG_NETWORK_ERROR } from "@lib/services/lib/logUtils.ts"; setNoticeClass(Notice); @@ -236,7 +237,7 @@ export class ModuleObsidianAPI extends AbstractObsidianModule { } catch (ex: any) { this._log(`HTTP:${method}${size} to:${localURL} -> failed`, LOG_LEVEL_VERBOSE); const msg = ex instanceof Error ? `${ex?.name}:${ex?.message}` : ex?.toString(); - this.showError(`\u{200b}Network Error: Failed to fetch: ${msg}`); // Do not show notice, due to throwing below + this.showError(`${MARK_LOG_NETWORK_ERROR}Network Error: Failed to fetch: ${msg}`); // Do not show notice, due to throwing below this._log(ex, LOG_LEVEL_VERBOSE); // limit only in bulk_docs. if (url.toString().indexOf("_bulk_docs") !== -1) { diff --git a/src/modules/features/ModuleLog.ts b/src/modules/features/ModuleLog.ts index e743a10..7d9c3e9 100644 --- a/src/modules/features/ModuleLog.ts +++ b/src/modules/features/ModuleLog.ts @@ -39,7 +39,7 @@ import { isValidFilenameInDarwin, isValidFilenameInWidows, } from "@lib/string_and_binary/path.ts"; -import { MARK_LOG_SEPARATOR } from "@lib/services/lib/logUtils.ts"; +import { MARK_LOG_NETWORK_ERROR, MARK_LOG_SEPARATOR } from "@lib/services/lib/logUtils.ts"; import { NetworkWarningStyles } from "@lib/common/models/setting.const.ts"; // This module cannot be a core module because it depends on the Obsidian UI. @@ -284,8 +284,8 @@ export class ModuleLog extends AbstractObsidianModule { if (fileStatus && !this.settings.hideFileWarningNotice) messageLines.push(fileStatus); const messages = (await this.services.appLifecycle.getUnresolvedMessages()).flat().filter((e) => e); const stringMessages = messages.filter((m): m is string => typeof m === "string"); // for 'startsWith' - const networkMessages = stringMessages.filter((m) => m.startsWith("\u{200b}")); - const otherMessages = stringMessages.filter((m) => !m.startsWith("\u{200b}")); + const networkMessages = stringMessages.filter((m) => m.startsWith(MARK_LOG_NETWORK_ERROR)); + const otherMessages = stringMessages.filter((m) => !m.startsWith(MARK_LOG_NETWORK_ERROR)); messageLines.push(...otherMessages);