mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-09-21 18:17:05 +00:00
refactor: clarify startup operation defaults
This commit is contained in:
@@ -93,6 +93,12 @@ describe("useStartupLifecycleFeature default operation wiring", () => {
|
|||||||
log,
|
log,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(operationMocks.checkCompromisedChunks).not.toHaveBeenCalled();
|
||||||
|
expect(operationMocks.checkIncompleteDocuments).not.toHaveBeenCalled();
|
||||||
|
expect(operationMocks.runConfigDoctor).not.toHaveBeenCalled();
|
||||||
|
expect(operationMocks.migrateBulkSendSetting).not.toHaveBeenCalled();
|
||||||
|
expect(waitForCompatibilityReview).not.toHaveBeenCalled();
|
||||||
|
|
||||||
const layoutAdmission = addLayoutHandler.mock.calls[0]?.[0] as () => Promise<boolean>;
|
const layoutAdmission = addLayoutHandler.mock.calls[0]?.[0] as () => Promise<boolean>;
|
||||||
const firstInitialise = addFirstInitialiseHandler.mock.calls[0]?.[0] as () => Promise<boolean>;
|
const firstInitialise = addFirstInitialiseHandler.mock.calls[0]?.[0] as () => Promise<boolean>;
|
||||||
await expect(layoutAdmission()).resolves.toBe(true);
|
await expect(layoutAdmission()).resolves.toBe(true);
|
||||||
|
|||||||
@@ -26,69 +26,68 @@ function createDefaultOperations(
|
|||||||
log: ReturnType<typeof createInstanceLogFunction>
|
log: ReturnType<typeof createInstanceLogFunction>
|
||||||
): ConfiguredStartupLifecycleOperations {
|
): ConfiguredStartupLifecycleOperations {
|
||||||
const { services } = host;
|
const { services } = host;
|
||||||
return {
|
const defaultOperations = {
|
||||||
databaseReady: options.databaseReady ?? (() => services.database.localDatabase.isReady),
|
databaseReady: () => services.database.localDatabase.isReady,
|
||||||
reportDatabaseNotReady:
|
reportDatabaseNotReady: () => log($msg("moduleMigration.logLocalDatabaseNotReady"), LOG_LEVEL_NOTICE),
|
||||||
options.reportDatabaseNotReady ??
|
hasCompromisedChunks: () =>
|
||||||
(() => log($msg("moduleMigration.logLocalDatabaseNotReady"), LOG_LEVEL_NOTICE)),
|
checkCompromisedChunks({
|
||||||
hasCompromisedChunks:
|
settings: services.setting.currentSettings(),
|
||||||
options.hasCompromisedChunks ??
|
localDatabase: services.database.localDatabase,
|
||||||
(() =>
|
isOnline: () => services.API.isOnline,
|
||||||
checkCompromisedChunks({
|
getActiveReplicator: () => services.replicator.getActiveReplicator(),
|
||||||
settings: services.setting.currentSettings(),
|
confirm: services.UI.confirm,
|
||||||
|
rebuilder: host.serviceModules.rebuilder,
|
||||||
|
performRestart: () => services.appLifecycle.performRestart(),
|
||||||
|
log,
|
||||||
|
}),
|
||||||
|
hasIncompleteDocuments: (force = false) =>
|
||||||
|
checkIncompleteDocuments(
|
||||||
|
{
|
||||||
localDatabase: services.database.localDatabase,
|
localDatabase: services.database.localDatabase,
|
||||||
isOnline: () => services.API.isOnline,
|
getPath: (entry) => services.path.getPath(entry),
|
||||||
getActiveReplicator: () => services.replicator.getActiveReplicator(),
|
isTargetFile: (path) => services.vault.isTargetFile(path),
|
||||||
|
storageAccess: host.serviceModules.storageAccess,
|
||||||
|
fileHandler: host.serviceModules.fileHandler,
|
||||||
|
keyValueDB: services.keyValueDB.kvDB,
|
||||||
|
noticeGroups: services.context.noticeGroups,
|
||||||
confirm: services.UI.confirm,
|
confirm: services.UI.confirm,
|
||||||
|
log,
|
||||||
|
},
|
||||||
|
force
|
||||||
|
),
|
||||||
|
runDoctor: (skipRebuild = false, activateReason = "updated", forceRescan = false) =>
|
||||||
|
runConfigDoctor(
|
||||||
|
{
|
||||||
|
confirm: services.UI.confirm,
|
||||||
|
translate: services.context.translate,
|
||||||
|
settings: services.setting.currentSettings(),
|
||||||
|
setSettings: (settings) => {
|
||||||
|
services.setting.settings = settings;
|
||||||
|
},
|
||||||
|
saveSettings: () => services.setting.saveSettingData(),
|
||||||
rebuilder: host.serviceModules.rebuilder,
|
rebuilder: host.serviceModules.rebuilder,
|
||||||
performRestart: () => services.appLifecycle.performRestart(),
|
performRestart: () => services.appLifecycle.performRestart(),
|
||||||
log,
|
},
|
||||||
})),
|
skipRebuild,
|
||||||
hasIncompleteDocuments:
|
activateReason,
|
||||||
options.hasIncompleteDocuments ??
|
forceRescan
|
||||||
((force = false) =>
|
),
|
||||||
checkIncompleteDocuments(
|
migrateBulkSend: () =>
|
||||||
{
|
migrateBulkSendSetting({
|
||||||
localDatabase: services.database.localDatabase,
|
settings: services.setting.currentSettings(),
|
||||||
getPath: (entry) => services.path.getPath(entry),
|
log,
|
||||||
isTargetFile: (path) => services.vault.isTargetFile(path),
|
saveSettings: () => services.setting.saveSettingData(),
|
||||||
storageAccess: host.serviceModules.storageAccess,
|
}),
|
||||||
fileHandler: host.serviceModules.fileHandler,
|
} satisfies Omit<ConfiguredStartupLifecycleOperations, "waitForCompatibilityReview">;
|
||||||
keyValueDB: services.keyValueDB.kvDB,
|
|
||||||
noticeGroups: services.context.noticeGroups,
|
return {
|
||||||
confirm: services.UI.confirm,
|
databaseReady: options.databaseReady ?? defaultOperations.databaseReady,
|
||||||
log,
|
reportDatabaseNotReady: options.reportDatabaseNotReady ?? defaultOperations.reportDatabaseNotReady,
|
||||||
},
|
hasCompromisedChunks: options.hasCompromisedChunks ?? defaultOperations.hasCompromisedChunks,
|
||||||
force
|
hasIncompleteDocuments: options.hasIncompleteDocuments ?? defaultOperations.hasIncompleteDocuments,
|
||||||
)),
|
|
||||||
waitForCompatibilityReview: options.waitForCompatibilityReview,
|
waitForCompatibilityReview: options.waitForCompatibilityReview,
|
||||||
runDoctor:
|
runDoctor: options.runDoctor ?? defaultOperations.runDoctor,
|
||||||
options.runDoctor ??
|
migrateBulkSend: options.migrateBulkSend ?? defaultOperations.migrateBulkSend,
|
||||||
((skipRebuild = false, activateReason = "updated", forceRescan = false) =>
|
|
||||||
runConfigDoctor(
|
|
||||||
{
|
|
||||||
confirm: services.UI.confirm,
|
|
||||||
translate: services.context.translate,
|
|
||||||
settings: services.setting.currentSettings(),
|
|
||||||
setSettings: (settings) => {
|
|
||||||
services.setting.settings = settings;
|
|
||||||
},
|
|
||||||
saveSettings: () => services.setting.saveSettingData(),
|
|
||||||
rebuilder: host.serviceModules.rebuilder,
|
|
||||||
performRestart: () => services.appLifecycle.performRestart(),
|
|
||||||
},
|
|
||||||
skipRebuild,
|
|
||||||
activateReason,
|
|
||||||
forceRescan
|
|
||||||
)),
|
|
||||||
migrateBulkSend:
|
|
||||||
options.migrateBulkSend ??
|
|
||||||
(() =>
|
|
||||||
migrateBulkSendSetting({
|
|
||||||
settings: services.setting.currentSettings(),
|
|
||||||
log,
|
|
||||||
saveSettings: () => services.setting.saveSettingData(),
|
|
||||||
})),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
@@ -12,6 +12,16 @@ Earlier releases remain available in the 1.0 release history, the 1.0 preview hi
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Synchronisation and storage
|
||||||
|
|
||||||
|
#### Improved
|
||||||
|
|
||||||
|
- Start-up now keeps unconfigured Vaults on the onboarding path without running configured-only checks or accepting Config Doctor and incomplete-document repair requests. Returning a configured Vault to an unconfigured state also retires those requests for the current plug-in process, so completing setup admits them only after the requested restart.
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
- Start-up migrations, integrity checks, Config Doctor, basic commands, and the Obsidian replication ribbon now have focused regression tests for their service composition. Real Obsidian checks cover unconfigured onboarding, configured start-up scanning, Config Doctor detection and layout, command registration, and the established ribbon icon.
|
||||||
|
|
||||||
## 1.0.24
|
## 1.0.24
|
||||||
|
|
||||||
3rd September, 2026
|
3rd September, 2026
|
||||||
|
|||||||
Reference in New Issue
Block a user