mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-13 21:02:30 +00:00
prettify
This commit is contained in:
@@ -29,10 +29,16 @@ import { decodeSettingsFromQRCodeData } from "@lib/API/processSetting.ts";
|
|||||||
import { AbstractModule } from "../AbstractModule.ts";
|
import { AbstractModule } from "../AbstractModule.ts";
|
||||||
import { ConnectionStringParser } from "@lib/common/ConnectionString.ts";
|
import { ConnectionStringParser } from "@lib/common/ConnectionString.ts";
|
||||||
import type {
|
import type {
|
||||||
OutroAskUserModeResultType, OutroExistingUserResultType, OutroNewUserResultType,
|
OutroAskUserModeResultType,
|
||||||
ScanQRCodeResultType, SetupRemoteBucketResultType, SetupRemoteCouchDBResultType,
|
OutroExistingUserResultType,
|
||||||
SetupRemoteE2EEResultType, SetupRemoteP2PResultType,
|
OutroNewUserResultType,
|
||||||
SetupRemoteResultType, UseSetupURIResultType
|
ScanQRCodeResultType,
|
||||||
|
SetupRemoteBucketResultType,
|
||||||
|
SetupRemoteCouchDBResultType,
|
||||||
|
SetupRemoteE2EEResultType,
|
||||||
|
SetupRemoteP2PResultType,
|
||||||
|
SetupRemoteResultType,
|
||||||
|
UseSetupURIResultType,
|
||||||
} from "./SetupWizard/dialogs/setupDialogTypes.ts";
|
} 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
|
* @returns Promise that resolves to true if onboarding completed successfully, false otherwise
|
||||||
*/
|
*/
|
||||||
async onUseSetupURI(userMode: UserMode, setupURI: string = ""): Promise<boolean> {
|
async onUseSetupURI(userMode: UserMode, setupURI: string = ""): Promise<boolean> {
|
||||||
const newSetting = await this.dialogManager.openWithExplicitCancel<UseSetupURIResultType, string>(UseSetupURI, setupURI);
|
const newSetting = await this.dialogManager.openWithExplicitCancel<UseSetupURIResultType, string>(
|
||||||
|
UseSetupURI,
|
||||||
|
setupURI
|
||||||
|
);
|
||||||
if (newSetting === "cancelled") {
|
if (newSetting === "cancelled") {
|
||||||
this._log("Setup URI dialog cancelled.", LOG_LEVEL_NOTICE);
|
this._log("Setup URI dialog cancelled.", LOG_LEVEL_NOTICE);
|
||||||
return false;
|
return false;
|
||||||
@@ -151,7 +160,10 @@ export class SetupManager extends AbstractModule {
|
|||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const originalSetting = JSON.parse(JSON.stringify(currentSetting)) as ObsidianLiveSyncSettings;
|
const originalSetting = JSON.parse(JSON.stringify(currentSetting)) as ObsidianLiveSyncSettings;
|
||||||
const baseSetting = JSON.parse(JSON.stringify(originalSetting)) as ObsidianLiveSyncSettings;
|
const baseSetting = JSON.parse(JSON.stringify(originalSetting)) as ObsidianLiveSyncSettings;
|
||||||
const couchConf = await this.dialogManager.openWithExplicitCancel<SetupRemoteCouchDBResultType, CouchDBConnection>(SetupRemoteCouchDB, originalSetting);
|
const couchConf = await this.dialogManager.openWithExplicitCancel<
|
||||||
|
SetupRemoteCouchDBResultType,
|
||||||
|
CouchDBConnection
|
||||||
|
>(SetupRemoteCouchDB, originalSetting);
|
||||||
if (couchConf === "cancelled") {
|
if (couchConf === "cancelled") {
|
||||||
this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE);
|
this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE);
|
||||||
return await this.onOnboard(userMode);
|
return await this.onOnboard(userMode);
|
||||||
@@ -175,7 +187,10 @@ export class SetupManager extends AbstractModule {
|
|||||||
currentSetting: ObsidianLiveSyncSettings,
|
currentSetting: ObsidianLiveSyncSettings,
|
||||||
activate = true
|
activate = true
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const bucketConf = await this.dialogManager.openWithExplicitCancel<SetupRemoteBucketResultType, BucketSyncSetting>(SetupRemoteBucket, currentSetting);
|
const bucketConf = await this.dialogManager.openWithExplicitCancel<
|
||||||
|
SetupRemoteBucketResultType,
|
||||||
|
BucketSyncSetting
|
||||||
|
>(SetupRemoteBucket, currentSetting);
|
||||||
if (bucketConf === "cancelled") {
|
if (bucketConf === "cancelled") {
|
||||||
this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE);
|
this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE);
|
||||||
return await this.onOnboard(userMode);
|
return await this.onOnboard(userMode);
|
||||||
@@ -199,7 +214,10 @@ export class SetupManager extends AbstractModule {
|
|||||||
currentSetting: ObsidianLiveSyncSettings,
|
currentSetting: ObsidianLiveSyncSettings,
|
||||||
activate = true
|
activate = true
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const p2pConf = await this.dialogManager.openWithExplicitCancel<SetupRemoteP2PResultType, P2PSyncSetting>(SetupRemoteP2P, currentSetting);
|
const p2pConf = await this.dialogManager.openWithExplicitCancel<SetupRemoteP2PResultType, P2PSyncSetting>(
|
||||||
|
SetupRemoteP2P,
|
||||||
|
currentSetting
|
||||||
|
);
|
||||||
if (p2pConf === "cancelled") {
|
if (p2pConf === "cancelled") {
|
||||||
this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE);
|
this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE);
|
||||||
return await this.onOnboard(userMode);
|
return await this.onOnboard(userMode);
|
||||||
@@ -234,7 +252,10 @@ export class SetupManager extends AbstractModule {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async onlyE2EEConfiguration(userMode: UserMode, currentSetting: ObsidianLiveSyncSettings): Promise<boolean> {
|
async onlyE2EEConfiguration(userMode: UserMode, currentSetting: ObsidianLiveSyncSettings): Promise<boolean> {
|
||||||
const e2eeConf = await this.dialogManager.openWithExplicitCancel<SetupRemoteE2EEResultType, EncryptionSettings>(SetupRemoteE2EE, currentSetting);
|
const e2eeConf = await this.dialogManager.openWithExplicitCancel<SetupRemoteE2EEResultType, EncryptionSettings>(
|
||||||
|
SetupRemoteE2EE,
|
||||||
|
currentSetting
|
||||||
|
);
|
||||||
if (e2eeConf === "cancelled") {
|
if (e2eeConf === "cancelled") {
|
||||||
this._log("E2EE configuration cancelled.", LOG_LEVEL_NOTICE);
|
this._log("E2EE configuration cancelled.", LOG_LEVEL_NOTICE);
|
||||||
return false;
|
return false;
|
||||||
@@ -253,7 +274,10 @@ export class SetupManager extends AbstractModule {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async onConfigureManually(originalSetting: ObsidianLiveSyncSettings, userMode: UserMode): Promise<boolean> {
|
async onConfigureManually(originalSetting: ObsidianLiveSyncSettings, userMode: UserMode): Promise<boolean> {
|
||||||
const e2eeConf = await this.dialogManager.openWithExplicitCancel<SetupRemoteE2EEResultType, EncryptionSettings>(SetupRemoteE2EE, originalSetting);
|
const e2eeConf = await this.dialogManager.openWithExplicitCancel<SetupRemoteE2EEResultType, EncryptionSettings>(
|
||||||
|
SetupRemoteE2EE,
|
||||||
|
originalSetting
|
||||||
|
);
|
||||||
if (e2eeConf === "cancelled") {
|
if (e2eeConf === "cancelled") {
|
||||||
this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE);
|
this._log("Manual configuration cancelled.", LOG_LEVEL_NOTICE);
|
||||||
return await this.onOnboard(userMode);
|
return await this.onOnboard(userMode);
|
||||||
@@ -300,7 +324,7 @@ export class SetupManager extends AbstractModule {
|
|||||||
newConf: ObsidianLiveSyncSettings,
|
newConf: ObsidianLiveSyncSettings,
|
||||||
_userMode: UserMode,
|
_userMode: UserMode,
|
||||||
activate: boolean = true,
|
activate: boolean = true,
|
||||||
extra: () => void = () => { }
|
extra: () => void = () => {}
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
newConf = await this.services.setting.adjustSettings({
|
newConf = await this.services.setting.adjustSettings({
|
||||||
...this.settings,
|
...this.settings,
|
||||||
@@ -331,7 +355,8 @@ export class SetupManager extends AbstractModule {
|
|||||||
this._log("Settings from wizard applied.", LOG_LEVEL_NOTICE);
|
this._log("Settings from wizard applied.", LOG_LEVEL_NOTICE);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
const userModeResult = await this.dialogManager.openWithExplicitCancel<OutroAskUserModeResultType>(OutroAskUserMode);
|
const userModeResult =
|
||||||
|
await this.dialogManager.openWithExplicitCancel<OutroAskUserModeResultType>(OutroAskUserMode);
|
||||||
if (userModeResult === "new-user") {
|
if (userModeResult === "new-user") {
|
||||||
userMode = UserMode.NewUser;
|
userMode = UserMode.NewUser;
|
||||||
} else if (userModeResult === "existing-user") {
|
} else if (userModeResult === "existing-user") {
|
||||||
@@ -348,7 +373,9 @@ export class SetupManager extends AbstractModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const component = userMode === UserMode.NewUser ? OutroNewUser : OutroExistingUser;
|
const component = userMode === UserMode.NewUser ? OutroNewUser : OutroExistingUser;
|
||||||
const confirm = await this.dialogManager.openWithExplicitCancel<OutroNewUserResultType | OutroExistingUserResultType>(component);
|
const confirm = await this.dialogManager.openWithExplicitCancel<
|
||||||
|
OutroNewUserResultType | OutroExistingUserResultType
|
||||||
|
>(component);
|
||||||
if (confirm === "cancelled") {
|
if (confirm === "cancelled") {
|
||||||
this._log("User cancelled applying settings from wizard..", LOG_LEVEL_NOTICE);
|
this._log("User cancelled applying settings from wizard..", LOG_LEVEL_NOTICE);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ import { extractObject } from "octagonal-wheels/object";
|
|||||||
import { REMOTE_MINIO, REMOTE_P2P } from "@lib/common/models/setting.const";
|
import { REMOTE_MINIO, REMOTE_P2P } from "@lib/common/models/setting.const";
|
||||||
import type { ObsidianLiveSyncSettings } from "@lib/common/models/setting.type";
|
import type { ObsidianLiveSyncSettings } from "@lib/common/models/setting.type";
|
||||||
import { TweakValuesShouldMatchedTemplate } from "@lib/common/models/tweak.definition";
|
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.
|
* Flag file handler interface, similar to target filter pattern.
|
||||||
@@ -66,7 +69,8 @@ export function createFetchAllFlagHandler(
|
|||||||
|
|
||||||
// Handle the fetch all scheduled operation
|
// Handle the fetch all scheduled operation
|
||||||
const onScheduled = async () => {
|
const onScheduled = async () => {
|
||||||
const method = await host.services.UI.dialogManager.openWithExplicitCancel<FetchEverythingResult>(FetchEverything);
|
const method =
|
||||||
|
await host.services.UI.dialogManager.openWithExplicitCancel<FetchEverythingResult>(FetchEverything);
|
||||||
if (method === "cancelled") {
|
if (method === "cancelled") {
|
||||||
log("Fetch everything cancelled by user.", LOG_LEVEL_NOTICE);
|
log("Fetch everything cancelled by user.", LOG_LEVEL_NOTICE);
|
||||||
await cleanupFlag();
|
await cleanupFlag();
|
||||||
@@ -297,7 +301,8 @@ export function createRebuildFlagHandler(
|
|||||||
|
|
||||||
// Handle the rebuild everything scheduled operation
|
// Handle the rebuild everything scheduled operation
|
||||||
const onScheduled = async () => {
|
const onScheduled = async () => {
|
||||||
const method = await host.services.UI.dialogManager.openWithExplicitCancel<RebuildEverythingResult>(RebuildEverything);
|
const method =
|
||||||
|
await host.services.UI.dialogManager.openWithExplicitCancel<RebuildEverythingResult>(RebuildEverything);
|
||||||
if (method === "cancelled") {
|
if (method === "cancelled") {
|
||||||
log("Rebuild everything cancelled by user.", LOG_LEVEL_NOTICE);
|
log("Rebuild everything cancelled by user.", LOG_LEVEL_NOTICE);
|
||||||
await cleanupFlag();
|
await cleanupFlag();
|
||||||
|
|||||||
Reference in New Issue
Block a user