Skip to content

Commit

Permalink
feat(tree): make one init for everything (#564)
Browse files Browse the repository at this point in the history
* feat(tree): make one init for everything

* refactor: maybe fix test

---------

Co-authored-by: Henrik Bossart <[email protected]>
  • Loading branch information
ingeridhellen and henrikbossart authored Oct 2, 2023
1 parent abaa082 commit 8510162
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/dm-core/src/domain/Tree.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AxiosResponse } from 'axios'
import { splitAddress } from '../utils/addressUtilities'
import { EBlueprint } from '../Enums'
import { useDMSS } from '../context/DMSSContext'
import { DmssAPI } from '../services'
Expand Down Expand Up @@ -268,6 +269,18 @@ export class Tree {
this.updateCallback = updateCallback
}

async init(path?: string[]) {
if (!path) {
this.initFromDataSources()
return
}
path
.filter((x) => splitAddress(x).documentPath)
.forEach((x) => this.initFromPath(x))
const dataSources = path.filter((x) => !splitAddress(x).documentPath)
if (dataSources.length) this.initFromDataSources(dataSources)
}

async initFromDataSources(dataSources?: string[]) {
// Add the dataSources as the top-level nodes
const allDataSources = await this.dmssApi
Expand Down

0 comments on commit 8510162

Please sign in to comment.