Skip to content

Commit

Permalink
Automatically add a display if none is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jun 14, 2024
1 parent 99e06fb commit 665f843
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
16 changes: 15 additions & 1 deletion packages/core/pluggableElementTypes/models/BaseTrackModel.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { transaction } from 'mobx'
import { autorun, transaction } from 'mobx'
import {
getRoot,
resolveIdentifier,
types,
Instance,
IAnyStateTreeNode,
addDisposer,
} from 'mobx-state-tree'

// locals
Expand Down Expand Up @@ -210,6 +211,19 @@ export function createBaseTrackModel(
: []),
]
},
afterAttach() {
addDisposer(
self,
autorun(() => {
if (!self.displays.length) {
const compatDisp = getCompatibleDisplays(self)
self.showDisplay(
self.configuration.trackId + '-' + compatDisp[0].type,
)
}
}),
)
},
}))
}

Expand Down
27 changes: 6 additions & 21 deletions test_data/volvox/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,34 +218,19 @@
},
"connections": [],
"defaultSession": {
"name": "Integration test example",
"name": "New Default Session",
"views": [
{
"id": "integration_test",
"id": "LinearGenomeView-1",
"type": "LinearGenomeView",
"offsetPx": 2000,
"bpPerPx": 0.05,
"displayedRegions": [
"tracks": [
{
"refName": "ctgA",
"start": 0,
"end": 50001,
"assemblyName": "volvox"
"type": "FeatureTrack",
"configuration": "gff3tabix_genes"
}
]
}
],
"widgets": {
"hierarchicalTrackSelector": {
"id": "hierarchicalTrackSelector",
"type": "HierarchicalTrackSelectorWidget",
"filterText": "",
"view": "integration_test"
}
},
"activeWidgets": {
"hierarchicalTrackSelector": "hierarchicalTrackSelector"
}
]
},
"tracks": [
{
Expand Down

0 comments on commit 665f843

Please sign in to comment.