Architecture

Summary

Lookup command lifecycle

Lifecycle

Lookup


  • 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

        • @prepareQuickPick (Private)

          • PickerUtilsV2.createDendronQuickPick -> DendronQuickPickerV2
          • ...
        • @showQuickPick (Private)

          • 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(...)
  1. Lookup factory created as part of dendron extension on startup

Code Snippets

class DendronExtension { 
  constructor { 
    ...
    @lookupControllerFactory = new LookupControllerV3Factory
  }
}
create { 
  ...
  return new LookupControllerV3
}

See the Sequence Diagram.

Components

The Lookup Control uses a pseudo MVVM pattern.

  1. LookupControllerV3.ts is the 'model' / controller.
  2. A view model in LookupViewModel.ts represents the data state for the lookup options.
  3. 2 views subscribe to the view model
    1. A QuickPickView, which represents the UI state of the buttons in the quick pick.
    2. A LookupPanelView, which represents the view for the LookupPanel webview on the side.

So essentially:

graph LR A(Lookup Controller V3) <-->|Responds to State Changes| B(Lookup View Model) B<-->|Two Way Binding| C(Quick Pick View) B<-->|Two Way Binding| D(Lookup Panel View)

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.

Questions

How to switch to sqlite mode?

metadataStore = "sqlite" see Architecture


Children
  1. Seq Diagram

Backlinks