Architecture
Summary
Lookup command lifecycle
Lifecycle
Lookup
-
src/web/commands/lookup/NoteLookupProvider.ts:fetchPickerResults
- @engine.queryNotesMeta (Private) (EngineAPIService) -> src/services/EngineAPIService.ts
-
EngineAPIService constructor - wrapper around API and event emitter
- EngineAPIService.cons( engineClient: DEngineClient (api proxy) engineEvents: EngineEventEmitter )
- @_internalEngine.queryNotesMeta (Private)({qs}) (DendronEngineClient) -> src/engineClient.ts // calls API
- calls API which calls DendronEngineV3 extending EngineV3Base
- EngineV3Base.queryNotesMeta > src/engine/EngineV3Base.ts
- @noteStore.queryMetadata (Private)
-
NoteStore init at src/DendronEngineV3Factory.ts
- defined in src/store/NoteStore.ts
- @_metadataStore.query (Private)
-
- @noteStore.queryMetadata (Private)
-
- @engine.queryNotesMeta (Private) (EngineAPIService) -> src/services/EngineAPIService.ts
-
src/DendronEngineV3.ts
- SQLiteMetadataStore.search(qs) if (config.workspace.metadataStore === "sqlite")
- src/enginev2.ts:queryNotesMeta
- src/engineClient.ts: queryNotesMeta
- SQLiteMetadataStore.search if config.workspace.metadataStore === "sqlite" ^wegk01mpsdcv
- src/drivers/PrismaSQLiteMetadataStore.ts:search
- src/engineClient.ts:queryNotes
- ConfigService.readConfig
- if sqlite:
- SQLiteMetadataStore.search
- noteProps.filter { vault }
- return
Initialization
-
src/workspace.ts:DendronExtension { new LookupControllerV3Factory }
-
src/components/lookup/LookupControllerV3Factory.ts { new LookupControllerV3 }
-
...
-
src/components/lookup/LookupControllerV3:show
-
- PickerUtilsV2.createDendronQuickPick -> DendronQuickPickerV2
- ...
-
-
quickpick.show
-
provider.onUpdatePickerItems
-
src/components/lookup/NoteLookupProvider.ts:onUpdatePickerItems
-
...
-
pickerValue = NoteLookupUtils.getQsForCurrentLevel(pickerValue)
-
queryOrig = NoteLookupUtils.slashToDot(picker.value)
-
return NotePickerUtils.fetchRootQuickPickResults if queryString == ""
-
items: NoteQuickInputV2[] = [...picker.items]
-
updatedItems = PickerUtilsV2.filterDefaultItems(items)
-
updatedItems = await NotePickerUtils.fetchPickerResults > src/components/lookup/NotePickerUtils.ts
- engine.queryNotesMeta
-
... schema logic
-
... filter middleware
-
... other logic
-
picker.items = updatedItems
-
-
-
provider.provide
- quickpick.onDidChangeValue(onUpdateDebounced)
- quickpick.onDidAccept
- quickpick.selectedItems[0].fname = quickpick.value
- @onDidAccept (Private)
- selectedItems = NotePickerUtils.getSelection
- ...
- this._onAcceptHooks.map(...)
-
-
-
-
- Lookup factory created as part of dendron extension on startup
Code Snippets
class DendronExtension {
constructor {
...
@lookupControllerFactory = new LookupControllerV3Factory
}
}
- ../packages/plugin-core/src/components/lookup/LookupControllerV3Factory.ts (Private)
- class: LookupControllerV3Factory
create {
...
return new LookupControllerV3
}
See the Sequence Diagram.
Components
The Lookup Control uses a pseudo MVVM pattern.
LookupControllerV3.ts
is the 'model' / controller.- A view model in
LookupViewModel.ts
represents the data state for the lookup options. - 2 views subscribe to the view model
- A QuickPickView, which represents the UI state of the buttons in the quick pick.
- A LookupPanelView, which represents the view for the LookupPanel webview on the side.
So essentially:
Note: The arrows in the diagram are supposed to be bi-directional
The views in this case are not true views as typically found in MVVM - rather, they are proxies for the views - For the QuickPickView, it can be thought of as a proxy to the vscode QuickPick
control component, whereas for the LookupPanelView, it can be thought of as a proxy to the React based webview component.
Related
Questions
How to switch to sqlite mode?
metadataStore = "sqlite" see Architecture
Children
Backlinks