diff --git a/src/lib b/src/lib index 61741c1..4d5adcd 160000 --- a/src/lib +++ b/src/lib @@ -1 +1 @@ -Subproject commit 61741c1748a48796a4f8ba0ea83ccde5f4e848fa +Subproject commit 4d5adcdee0a5ce4ace6f10881601071038b645ae diff --git a/src/modules/features/SettingDialogue/PaneHatch.ts b/src/modules/features/SettingDialogue/PaneHatch.ts index d9ca27c..18c878f 100644 --- a/src/modules/features/SettingDialogue/PaneHatch.ts +++ b/src/modules/features/SettingDialogue/PaneHatch.ts @@ -1,29 +1,16 @@ -import { stringifyYaml } from "../../../deps.ts"; import { - type ObsidianLiveSyncSettings, type FilePathWithPrefix, type DocumentID, LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE, type LoadedEntry, - REMOTE_COUCHDB, - REMOTE_MINIO, type MetaEntry, type FilePath, - DEFAULT_SETTINGS, -} from "../../../lib/src/common/types.ts"; -import { - createBlob, - getFileRegExp, - isDocContentSame, - parseHeaderValues, - readAsBlob, -} from "../../../lib/src/common/utils.ts"; -import { Logger } from "../../../lib/src/common/logger.ts"; -import { isCloudantURI } from "../../../lib/src/pouchdb/utils_couchdb.ts"; -import { requestToCouchDBWithCredentials } from "../../../common/utils.ts"; -import { addPrefix, shouldBeIgnored, stripAllPrefixes } from "../../../lib/src/string_and_binary/path.ts"; -import { $msg } from "../../../lib/src/common/i18n.ts"; +} from "@lib/common/types.ts"; +import { createBlob, getFileRegExp, isDocContentSame, readAsBlob } from "@lib/common/utils.ts"; +import { Logger } from "@lib/common/logger.ts"; +import { addPrefix, shouldBeIgnored, stripAllPrefixes } from "@lib/string_and_binary/path.ts"; +import { $msg } from "@lib/common/i18n.ts"; import { Semaphore } from "octagonal-wheels/concurrency/semaphore"; import { LiveSyncSetting as Setting } from "./LiveSyncSetting.ts"; import { @@ -32,14 +19,13 @@ import { EVENT_REQUEST_RUN_DOCTOR, EVENT_REQUEST_RUN_FIX_INCOMPLETE, eventHub, -} from "../../../common/events.ts"; -import { ICHeader, ICXHeader, PSCHeader } from "../../../common/types.ts"; -import { HiddenFileSync } from "../../../features/HiddenFileSync/CmdHiddenFileSync.ts"; -import { EVENT_REQUEST_SHOW_HISTORY } from "../../../common/obsidianEvents.ts"; -import { generateCredentialObject } from "../../../lib/src/replication/httplib.ts"; +} from "@/common/events.ts"; +import { ICHeader, ICXHeader, PSCHeader } from "@/common/types.ts"; +import { HiddenFileSync } from "@/features/HiddenFileSync/CmdHiddenFileSync.ts"; +import { EVENT_REQUEST_SHOW_HISTORY } from "@/common/obsidianEvents.ts"; import type { ObsidianLiveSyncSettingTab } from "./ObsidianLiveSyncSettingTab.ts"; import type { PageFunctions } from "./SettingPane.ts"; -import { generateReport } from "@/common/reportTool.ts"; +import { isNotFoundError } from "@lib/common/utils.doc.ts"; export function paneHatch(this: ObsidianLiveSyncSettingTab, paneEl: HTMLElement, { addPanel }: PageFunctions): void { // const hatchWarn = this.createEl(paneEl, "div", { text: `To stop the boot up sequence for fixing problems on databases, you can put redflag.md on top of your vault (Rebooting obsidian is required).` }); // hatchWarn.addClass("op-warn-info"); @@ -160,14 +146,14 @@ export function paneHatch(this: ObsidianLiveSyncSettingTab, paneEl: HTMLElement, } if (!(await addOn.storeInternalFileToDatabase(file, true))) { Logger( - `Failed to store the file to the database (Hidden file): ${file}`, + `Failed to store the file to the database (Hidden file): ${file.path}`, LOG_LEVEL_NOTICE ); return; } } } else { - if (!(await this.core.fileHandler.storeFileToDB(file as FilePath, true))) { + if (!(await this.core.fileHandler.storeFileToDB(file, true))) { Logger( `Failed to store the file to the database: ${file}`, LOG_LEVEL_NOTICE @@ -406,8 +392,8 @@ export function paneHatch(this: ObsidianLiveSyncSettingTab, paneEl: HTMLElement, Logger(`Converting ${docName} Failed!`, LOG_LEVEL_NOTICE); Logger(ret, LOG_LEVEL_VERBOSE); } - } catch (ex: any) { - if (ex?.status == 404) { + } catch (ex: unknown) { + if (isNotFoundError(ex)) { // We can perform this safely if ((await this.core.localDatabase.putRaw(newDoc)).ok) { Logger(`${docName} has been converted`, LOG_LEVEL_NOTICE); diff --git a/src/modules/services/ObsidianAPIService.ts b/src/modules/services/ObsidianAPIService.ts index 9f19c2d..2ac8d76 100644 --- a/src/modules/services/ObsidianAPIService.ts +++ b/src/modules/services/ObsidianAPIService.ts @@ -5,9 +5,17 @@ import { ObsHttpHandler } from "../essentialObsidian/APILib/ObsHttpHandler"; import { ObsidianConfirm } from "./ObsidianConfirm"; import type { Confirm } from "@lib/interfaces/Confirm"; import { requestUrl, type RequestUrlParam } from "@/deps"; +import { compatGlobal } from "@/lib/src/common/coreEnvFunctions"; // All Services will be migrated to be based on Plain Services, not Injectable Services. // This is a migration step. +declare module "obsidian" { + interface App { + appId?: string; + isMobile?: boolean; + } +} + export class ObsidianAPIService extends InjectableAPIService { _customHandler: ObsHttpHandler | undefined; _confirmInstance: Confirm; @@ -83,8 +91,7 @@ export class ObsidianAPIService extends InjectableAPIService= 2) { return match[1]; @@ -196,7 +203,7 @@ export class ObsidianAPIService extends InjectableAPIService void, timeout: number): number { - const timerId = globalThis.setInterval(handler, timeout) as unknown as number; + const timerId = compatGlobal.setInterval(handler, timeout); this.context.plugin.registerInterval(timerId); return timerId; }