Refactor startup promise orchestration#157
Refactor startup promise orchestration#157Mahathi-s154 wants to merge 1 commit intojoplin:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors startup async orchestration by removing the custom PromiseGroup abstraction and replacing it with a typed resolveNamedPromises helper, while simplifying other aggregation points to use native Promise.all.
Changes:
- Replace
PromiseGroupwithresolveNamedPromisesfor resolving keyed async dependencies. - Use
Promise.alldirectly for notebook display data aggregation and command registrations. - Add unit tests for
resolveNamedPromisesand ensure toolbar button creation happens after command registration completes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/utils/promises.ts |
Removes PromiseGroup and adds resolveNamedPromises for typed named-promise resolution. |
src/index.ts |
Updates startup logic to use resolveNamedPromises / Promise.all, and awaits command registration before creating toolbar buttons. |
tests/utils/promises.spec.ts |
Adds focused Jest coverage for resolveNamedPromises behavior (resolve/empty/reject). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| execute: async (folderId: string) => { | ||
| if (typeof folderId === "undefined") { | ||
| const selectedFolder = await joplin.workspace.selectedFolder(); | ||
| folderId = selectedFolder.id; | ||
| } | ||
| await joplin.clipboard.writeText(folderId); |
There was a problem hiding this comment.
In the copyFolderID command, the execute callback parameter is typed as folderId: string but the implementation explicitly handles it being undefined. This type mismatch can hide issues and makes the code harder to reason about under strict null checks. Update the signature to accept string | undefined (or make it optional) and prefer const effectiveId = folderId ?? (await joplin.workspace.selectedFolder()).id; to avoid reassigning the parameter.
| execute: async (folderId: string) => { | |
| if (typeof folderId === "undefined") { | |
| const selectedFolder = await joplin.workspace.selectedFolder(); | |
| folderId = selectedFolder.id; | |
| } | |
| await joplin.clipboard.writeText(folderId); | |
| execute: async (folderId?: string) => { | |
| const effectiveId = folderId ?? (await joplin.workspace.selectedFolder()).id; | |
| await joplin.clipboard.writeText(effectiveId); |
Summary
Testing