From 6ab1556880a54b2baa3a2431aaedfda5160589d8 Mon Sep 17 00:00:00 2001 From: vorotamoroz Date: Mon, 1 Jun 2026 11:19:32 +0100 Subject: [PATCH] prettify --- src/modules/features/SetupManager.ts | 53 +++++++++++++++++++++------- src/serviceFeatures/redFlag.ts | 11 ++++-- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/modules/features/SetupManager.ts b/src/modules/features/SetupManager.ts index 6bc2132..890a2cf 100644 --- a/src/modules/features/SetupManager.ts +++ b/src/modules/features/SetupManager.ts @@ -29,10 +29,16 @@ import { decodeSettingsFromQRCodeData } from "@lib/API/processSetting.ts"; import { AbstractModule } from "../AbstractModule.ts"; import { ConnectionStringParser } from "@lib/common/ConnectionString.ts"; import type { - OutroAskUserModeResultType, OutroExistingUserResultType, OutroNewUserResultType, - ScanQRCodeResultType, SetupRemoteBucketResultType, SetupRemoteCouchDBResultType, - SetupRemoteE2EEResultType, SetupRemoteP2PResultType, - SetupRemoteResultType, UseSetupURIResultType + OutroAskUserModeResultType, + OutroExistingUserResultType, + OutroNewUserResultType, + ScanQRCodeResultType, + SetupRemoteBucketResultType, + SetupRemoteCouchDBResultType, + SetupRemoteE2EEResultType, + SetupRemoteP2PResultType, + SetupRemoteResultType, + UseSetupURIResultType, } from "./SetupWizard/dialogs/setupDialogTypes.ts"; /** @@ -128,7 +134,10 @@ export class SetupManager extends AbstractModule { * @returns Promise that resolves to true if onboarding completed successfully, false otherwise */ async onUseSetupURI(userMode: UserMode, setupURI: string = ""): Promise { - const newSetting = await this.dialogManager.openWithExplicitCancel(UseSetupURI, setupURI); + const newSetting = await this.dialogManager.openWithExplicitCancel( + UseSetupURI, + setupURI + ); if (newSetting === "cancelled") { this._log("Setup URI dialog cancelled.", LOG_LEVEL_NOTICE); return false; @@ -151,7 +160,10 @@ export class SetupManager extends AbstractModule { ): Promise { const originalSetting = JSON.parse(JSON.stringify(currentSetting)) as ObsidianLiveSyncSettings; const baseSetting = JSON.parse(JSON.stringify(originalSetting)) as ObsidianLiveSyncSettings; - const couchConf = await this.dialogManager.openWithExplicitCancel(SetupRemoteCouchDB, originalSetting); + const couchConf = await this.dialogManager.openWithExplicitCancel< + SetupRemoteCouchDBResultType, + CouchDBConnection + >(SetupRemoteCouchDB, originalSetting); if (couchConf === "cancelled") { this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE); return await this.onOnboard(userMode); @@ -175,7 +187,10 @@ export class SetupManager extends AbstractModule { currentSetting: ObsidianLiveSyncSettings, activate = true ): Promise { - const bucketConf = await this.dialogManager.openWithExplicitCancel(SetupRemoteBucket, currentSetting); + const bucketConf = await this.dialogManager.openWithExplicitCancel< + SetupRemoteBucketResultType, + BucketSyncSetting + >(SetupRemoteBucket, currentSetting); if (bucketConf === "cancelled") { this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE); return await this.onOnboard(userMode); @@ -199,7 +214,10 @@ export class SetupManager extends AbstractModule { currentSetting: ObsidianLiveSyncSettings, activate = true ): Promise { - const p2pConf = await this.dialogManager.openWithExplicitCancel(SetupRemoteP2P, currentSetting); + const p2pConf = await this.dialogManager.openWithExplicitCancel( + SetupRemoteP2P, + currentSetting + ); if (p2pConf === "cancelled") { this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE); return await this.onOnboard(userMode); @@ -234,7 +252,10 @@ export class SetupManager extends AbstractModule { * @returns */ async onlyE2EEConfiguration(userMode: UserMode, currentSetting: ObsidianLiveSyncSettings): Promise { - const e2eeConf = await this.dialogManager.openWithExplicitCancel(SetupRemoteE2EE, currentSetting); + const e2eeConf = await this.dialogManager.openWithExplicitCancel( + SetupRemoteE2EE, + currentSetting + ); if (e2eeConf === "cancelled") { this._log("E2EE configuration cancelled.", LOG_LEVEL_NOTICE); return false; @@ -253,7 +274,10 @@ export class SetupManager extends AbstractModule { * @returns */ async onConfigureManually(originalSetting: ObsidianLiveSyncSettings, userMode: UserMode): Promise { - const e2eeConf = await this.dialogManager.openWithExplicitCancel(SetupRemoteE2EE, originalSetting); + const e2eeConf = await this.dialogManager.openWithExplicitCancel( + SetupRemoteE2EE, + originalSetting + ); if (e2eeConf === "cancelled") { this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE); return await this.onOnboard(userMode); @@ -300,7 +324,7 @@ export class SetupManager extends AbstractModule { newConf: ObsidianLiveSyncSettings, _userMode: UserMode, activate: boolean = true, - extra: () => void = () => { } + extra: () => void = () => {} ): Promise { newConf = await this.services.setting.adjustSettings({ ...this.settings, @@ -331,7 +355,8 @@ export class SetupManager extends AbstractModule { this._log("Settings from wizard applied.", LOG_LEVEL_NOTICE); return true; } else { - const userModeResult = await this.dialogManager.openWithExplicitCancel(OutroAskUserMode); + const userModeResult = + await this.dialogManager.openWithExplicitCancel(OutroAskUserMode); if (userModeResult === "new-user") { userMode = UserMode.NewUser; } else if (userModeResult === "existing-user") { @@ -348,7 +373,9 @@ export class SetupManager extends AbstractModule { } } const component = userMode === UserMode.NewUser ? OutroNewUser : OutroExistingUser; - const confirm = await this.dialogManager.openWithExplicitCancel(component); + const confirm = await this.dialogManager.openWithExplicitCancel< + OutroNewUserResultType | OutroExistingUserResultType + >(component); if (confirm === "cancelled") { this._log("User cancelled applying settings from wizard..", LOG_LEVEL_NOTICE); return false; diff --git a/src/serviceFeatures/redFlag.ts b/src/serviceFeatures/redFlag.ts index 75c9873..acfaf40 100644 --- a/src/serviceFeatures/redFlag.ts +++ b/src/serviceFeatures/redFlag.ts @@ -8,7 +8,10 @@ import { extractObject } from "octagonal-wheels/object"; import { REMOTE_MINIO, REMOTE_P2P } from "@lib/common/models/setting.const"; import type { ObsidianLiveSyncSettings } from "@lib/common/models/setting.type"; import { TweakValuesShouldMatchedTemplate } from "@lib/common/models/tweak.definition"; -import type { FetchEverythingResult, RebuildEverythingResult } from "@/modules/features/SetupWizard/dialogs/setupDialogTypes"; +import type { + FetchEverythingResult, + RebuildEverythingResult, +} from "@/modules/features/SetupWizard/dialogs/setupDialogTypes"; /** * Flag file handler interface, similar to target filter pattern. @@ -66,7 +69,8 @@ export function createFetchAllFlagHandler( // Handle the fetch all scheduled operation const onScheduled = async () => { - const method = await host.services.UI.dialogManager.openWithExplicitCancel(FetchEverything); + const method = + await host.services.UI.dialogManager.openWithExplicitCancel(FetchEverything); if (method === "cancelled") { log("Fetch everything cancelled by user.", LOG_LEVEL_NOTICE); await cleanupFlag(); @@ -297,7 +301,8 @@ export function createRebuildFlagHandler( // Handle the rebuild everything scheduled operation const onScheduled = async () => { - const method = await host.services.UI.dialogManager.openWithExplicitCancel(RebuildEverything); + const method = + await host.services.UI.dialogManager.openWithExplicitCancel(RebuildEverything); if (method === "cancelled") { log("Rebuild everything cancelled by user.", LOG_LEVEL_NOTICE); await cleanupFlag();