mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-27 11:33:21 +00:00
Simplify remote feature checks and clarify manual rebuild guidance
This commit is contained in:
1 parent
9a047d44f3
commit
2c6cd56618
15 files changed
+251
-684
No files matched your search
@@ -5,7 +5,6 @@ import {
|
||||
DEFAULT_SETTINGS,
|
||||
LOG_LEVEL_NOTICE,
|
||||
type ObsidianLiveSyncSettings,
|
||||
type EncryptionSettings,
|
||||
LOG_LEVEL_VERBOSE,
|
||||
} from "@vrtmrz/livesync-commonlib/compat/common/types";
|
||||
import { Menu, type ButtonComponent } from "@/deps.ts";
|
||||
@@ -32,13 +31,11 @@ import {
|
||||
import { ConnectionStringParser } from "@vrtmrz/livesync-commonlib/compat/common/ConnectionString";
|
||||
import type { RemoteConfigurationResult } from "@vrtmrz/livesync-commonlib/compat/common/ConnectionString";
|
||||
import SetupRemote from "@/modules/features/SetupWizard/dialogs/SetupRemote.svelte";
|
||||
import SetupRemoteE2EE from "@/modules/features/SetupWizard/dialogs/SetupRemoteE2EE.svelte";
|
||||
import SetupRemoteCouchDB from "@/modules/features/SetupWizard/dialogs/SetupRemoteCouchDB.svelte";
|
||||
import SetupRemoteBucket from "@/modules/features/SetupWizard/dialogs/SetupRemoteBucket.svelte";
|
||||
import type {
|
||||
SetupRemoteCouchDBInitialData,
|
||||
SetupRemoteCouchDBResultType,
|
||||
SetupRemoteE2EEResultType,
|
||||
} from "@/modules/features/SetupWizard/dialogs/setupDialogTypes.ts";
|
||||
import { syncActivatedRemoteSettings } from "./remoteConfigBuffer.ts";
|
||||
|
||||
@@ -119,34 +116,15 @@ export function paneRemoteConfig(
|
||||
.onClick(async () => {
|
||||
const setupManager = this.core.getModule(SetupManager);
|
||||
const originalSettings = getSettingsFromEditingSettings(this.editingSettings);
|
||||
const e2eeConf = await setupManager.dialogManager.openWithExplicitCancel<
|
||||
SetupRemoteE2EEResultType,
|
||||
EncryptionSettings
|
||||
>(SetupRemoteE2EE, originalSettings);
|
||||
if (e2eeConf === "cancelled") {
|
||||
return;
|
||||
}
|
||||
const onlyInternalMetadataPreferenceChanged =
|
||||
originalSettings.encryptInternalMetadata !== e2eeConf.encryptInternalMetadata &&
|
||||
originalSettings.encrypt === e2eeConf.encrypt &&
|
||||
originalSettings.passphrase === e2eeConf.passphrase &&
|
||||
originalSettings.E2EEAlgorithm === e2eeConf.E2EEAlgorithm &&
|
||||
originalSettings.usePathObfuscation === e2eeConf.usePathObfuscation;
|
||||
if (onlyInternalMetadataPreferenceChanged) {
|
||||
await this.services.setting.applyPartial(
|
||||
{ encryptInternalMetadata: e2eeConf.encryptInternalMetadata },
|
||||
true
|
||||
);
|
||||
this.editingSettings.encryptInternalMetadata = e2eeConf.encryptInternalMetadata;
|
||||
const applied = await setupManager.onlyE2EEConfiguration(UserMode.Update, originalSettings);
|
||||
if (applied) {
|
||||
this.editingSettings.encryptInternalMetadata =
|
||||
this.core.settings.encryptInternalMetadata;
|
||||
if (this.initialSettings) {
|
||||
this.initialSettings.encryptInternalMetadata = e2eeConf.encryptInternalMetadata;
|
||||
this.initialSettings.encryptInternalMetadata =
|
||||
this.core.settings.encryptInternalMetadata;
|
||||
}
|
||||
this.requestUpdate();
|
||||
} else {
|
||||
await setupManager.onConfirmApplySettingsFromWizard(
|
||||
{ ...originalSettings, ...e2eeConf },
|
||||
UserMode.Update
|
||||
);
|
||||
}
|
||||
updateE2EESummary();
|
||||
})
|
||||
|
||||
@@ -162,24 +162,15 @@ describe("paneRemoteConfig", () => {
|
||||
encryptInternalMetadata: false,
|
||||
remoteConfigurations: {},
|
||||
};
|
||||
const applyPartial = vi.fn(async () => {});
|
||||
const onConfirmApplySettingsFromWizard = vi.fn(async () => {});
|
||||
const setupManager = {
|
||||
dialogManager: {
|
||||
openWithExplicitCancel: vi.fn(async () => ({
|
||||
encrypt: true,
|
||||
passphrase: "passphrase",
|
||||
E2EEAlgorithm: "v2",
|
||||
usePathObfuscation: true,
|
||||
encryptInternalMetadata: true,
|
||||
})),
|
||||
},
|
||||
onConfirmApplySettingsFromWizard,
|
||||
onlyE2EEConfiguration: vi.fn(async () => {
|
||||
host.core.settings.encryptInternalMetadata = true;
|
||||
return true;
|
||||
}),
|
||||
};
|
||||
const host = {
|
||||
editingSettings: { ...originalSettings },
|
||||
initialSettings: { ...originalSettings },
|
||||
services: { setting: { applyPartial } },
|
||||
core: {
|
||||
settings: { ...originalSettings },
|
||||
getModule: vi.fn(() => setupManager),
|
||||
@@ -198,8 +189,7 @@ describe("paneRemoteConfig", () => {
|
||||
paneRemoteConfig.call(host as never, {} as HTMLElement, { addPanel } as never);
|
||||
await runtime.clickHandlers[0]();
|
||||
|
||||
expect(applyPartial).toHaveBeenCalledWith({ encryptInternalMetadata: true }, true);
|
||||
expect(onConfirmApplySettingsFromWizard).not.toHaveBeenCalled();
|
||||
expect(setupManager.onlyE2EEConfiguration).toHaveBeenCalledOnce();
|
||||
expect(host.editingSettings.encryptInternalMetadata).toBe(true);
|
||||
expect(host.initialSettings.encryptInternalMetadata).toBe(true);
|
||||
expect(host.requestUpdate).toHaveBeenCalledOnce();
|
||||
|
||||
Reference in new issue
Block a user