mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-09-09 04:07:07 +00:00
refactor: clarify startup operation defaults
This commit is contained in:
@@ -93,6 +93,12 @@ describe("useStartupLifecycleFeature default operation wiring", () => {
|
||||
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 firstInitialise = addFirstInitialiseHandler.mock.calls[0]?.[0] as () => Promise<boolean>;
|
||||
await expect(layoutAdmission()).resolves.toBe(true);
|
||||
|
||||
@@ -26,69 +26,68 @@ function createDefaultOperations(
|
||||
log: ReturnType<typeof createInstanceLogFunction>
|
||||
): ConfiguredStartupLifecycleOperations {
|
||||
const { services } = host;
|
||||
return {
|
||||
databaseReady: options.databaseReady ?? (() => services.database.localDatabase.isReady),
|
||||
reportDatabaseNotReady:
|
||||
options.reportDatabaseNotReady ??
|
||||
(() => log($msg("moduleMigration.logLocalDatabaseNotReady"), LOG_LEVEL_NOTICE)),
|
||||
hasCompromisedChunks:
|
||||
options.hasCompromisedChunks ??
|
||||
(() =>
|
||||
checkCompromisedChunks({
|
||||
settings: services.setting.currentSettings(),
|
||||
const defaultOperations = {
|
||||
databaseReady: () => services.database.localDatabase.isReady,
|
||||
reportDatabaseNotReady: () => log($msg("moduleMigration.logLocalDatabaseNotReady"), LOG_LEVEL_NOTICE),
|
||||
hasCompromisedChunks: () =>
|
||||
checkCompromisedChunks({
|
||||
settings: services.setting.currentSettings(),
|
||||
localDatabase: services.database.localDatabase,
|
||||
isOnline: () => services.API.isOnline,
|
||||
getActiveReplicator: () => services.replicator.getActiveReplicator(),
|
||||
confirm: services.UI.confirm,
|
||||
rebuilder: host.serviceModules.rebuilder,
|
||||
performRestart: () => services.appLifecycle.performRestart(),
|
||||
log,
|
||||
}),
|
||||
hasIncompleteDocuments: (force = false) =>
|
||||
checkIncompleteDocuments(
|
||||
{
|
||||
localDatabase: services.database.localDatabase,
|
||||
isOnline: () => services.API.isOnline,
|
||||
getActiveReplicator: () => services.replicator.getActiveReplicator(),
|
||||
getPath: (entry) => services.path.getPath(entry),
|
||||
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,
|
||||
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,
|
||||
performRestart: () => services.appLifecycle.performRestart(),
|
||||
log,
|
||||
})),
|
||||
hasIncompleteDocuments:
|
||||
options.hasIncompleteDocuments ??
|
||||
((force = false) =>
|
||||
checkIncompleteDocuments(
|
||||
{
|
||||
localDatabase: services.database.localDatabase,
|
||||
getPath: (entry) => services.path.getPath(entry),
|
||||
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,
|
||||
log,
|
||||
},
|
||||
force
|
||||
)),
|
||||
},
|
||||
skipRebuild,
|
||||
activateReason,
|
||||
forceRescan
|
||||
),
|
||||
migrateBulkSend: () =>
|
||||
migrateBulkSendSetting({
|
||||
settings: services.setting.currentSettings(),
|
||||
log,
|
||||
saveSettings: () => services.setting.saveSettingData(),
|
||||
}),
|
||||
} satisfies Omit<ConfiguredStartupLifecycleOperations, "waitForCompatibilityReview">;
|
||||
|
||||
return {
|
||||
databaseReady: options.databaseReady ?? defaultOperations.databaseReady,
|
||||
reportDatabaseNotReady: options.reportDatabaseNotReady ?? defaultOperations.reportDatabaseNotReady,
|
||||
hasCompromisedChunks: options.hasCompromisedChunks ?? defaultOperations.hasCompromisedChunks,
|
||||
hasIncompleteDocuments: options.hasIncompleteDocuments ?? defaultOperations.hasIncompleteDocuments,
|
||||
waitForCompatibilityReview: options.waitForCompatibilityReview,
|
||||
runDoctor:
|
||||
options.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,
|
||||
performRestart: () => services.appLifecycle.performRestart(),
|
||||
},
|
||||
skipRebuild,
|
||||
activateReason,
|
||||
forceRescan
|
||||
)),
|
||||
migrateBulkSend:
|
||||
options.migrateBulkSend ??
|
||||
(() =>
|
||||
migrateBulkSendSetting({
|
||||
settings: services.setting.currentSettings(),
|
||||
log,
|
||||
saveSettings: () => services.setting.saveSettingData(),
|
||||
})),
|
||||
runDoctor: options.runDoctor ?? defaultOperations.runDoctor,
|
||||
migrateBulkSend: options.migrateBulkSend ?? defaultOperations.migrateBulkSend,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -12,6 +12,16 @@ Earlier releases remain available in the 1.0 release history, the 1.0 preview hi
|
||||
|
||||
## 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
|
||||
|
||||
3rd September, 2026
|
||||
|
||||
Reference in New Issue
Block a user