@@ -2,20 +2,20 @@ import { lazy } from 'react'
22
33import { ConfigurationReference , getConf } from '@jbrowse/core/configuration'
44import {
5+ SessionWithWidgets ,
56 getContainingTrack ,
67 getContainingView ,
78 getEnv ,
89 getSession ,
910 max ,
1011 measureText ,
11- SessionWithWidgets ,
1212} from '@jbrowse/core/util'
1313import { getRpcSessionId } from '@jbrowse/core/util/tracks'
14+ import { addDisposer , isAlive , types } from '@jbrowse/mobx-state-tree'
1415import { ascending } from 'd3-array'
1516import { cluster , hierarchy } from 'd3-hierarchy'
1617import deepEqual from 'fast-deep-equal'
1718import { autorun } from 'mobx'
18- import { addDisposer , isAlive , types } from 'mobx-state-tree'
1919
2020import { computeNodeDescendantNames , maxLength , setBrLength } from './util'
2121import { normalize } from '../util'
@@ -26,9 +26,18 @@ import type {
2626 AnyConfigurationModel ,
2727 AnyConfigurationSchemaType ,
2828} from '@jbrowse/core/configuration'
29+ import type { Instance } from '@jbrowse/mobx-state-tree'
2930import type { ExportSvgDisplayOptions } from '@jbrowse/plugin-linear-genome-view'
3031import type { HierarchyNode } from 'd3-hierarchy'
31- import type { Instance } from 'mobx-state-tree'
32+
33+ const defaultRowHeight = 15
34+ const defaultRowProportion = 0.8
35+ const defaultShowAllLetters = false
36+ const defaultMismatchRendering = true
37+ const defaultShowBranchLen = false
38+ const defaultTreeAreaWidth = 80
39+ const defaultShowAsUpperCase = true
40+ const defaultShowSidebar = true
3241
3342const SetRowHeightDialog = lazy (
3443 ( ) => import ( './components/SetRowHeightDialog/SetRowHeightDialog' ) ,
@@ -63,37 +72,37 @@ export default function stateModelFactory(
6372 /**
6473 * #property
6574 */
66- rowHeight : 15 ,
75+ rowHeight : defaultRowHeight ,
6776 /**
6877 * #property
6978 */
70- rowProportion : 0.8 ,
79+ rowProportion : defaultRowProportion ,
7180 /**
7281 * #property
7382 */
74- showAllLetters : false ,
83+ showAllLetters : defaultShowAllLetters ,
7584 /**
7685 * #property
7786 */
78- mismatchRendering : true ,
87+ mismatchRendering : defaultMismatchRendering ,
7988
8089 /**
8190 * #property
8291 */
83- showBranchLen : false ,
92+ showBranchLen : defaultShowBranchLen ,
8493
8594 /**
8695 * #property
8796 */
88- treeAreaWidth : 80 ,
97+ treeAreaWidth : defaultTreeAreaWidth ,
8998 /**
9099 * #property
91100 */
92- showAsUpperCase : true ,
101+ showAsUpperCase : defaultShowAsUpperCase ,
93102 /**
94103 * #property
95104 */
96- showSidebar : true ,
105+ showSidebar : defaultShowSidebar ,
97106 } ) ,
98107 )
99108 . volatile ( ( ) => ( {
@@ -481,7 +490,11 @@ export default function stateModelFactory(
481490 ( v as { connectedViewId ?: string } ) . connectedViewId === view . id
482491 ) {
483492 const msaView = v as {
484- connectedHighlights ?: { refName : string ; start : number ; end : number } [ ]
493+ connectedHighlights ?: {
494+ refName : string
495+ start : number
496+ end : number
497+ } [ ]
485498 }
486499 if ( msaView . connectedHighlights ) {
487500 for ( const h of msaView . connectedHighlights ) {
@@ -537,7 +550,7 @@ export default function stateModelFactory(
537550 adapterConfig : self . adapterConfig ,
538551 statusCallback : ( message : string ) => {
539552 if ( isAlive ( self ) ) {
540- self . setMessage ( message )
553+ self . setStatusMessage ( message )
541554 }
542555 } ,
543556 } ) ) as { samples : Sample [ ] ; tree : NodeWithIds | undefined } ,
@@ -563,6 +576,43 @@ export default function stateModelFactory(
563576 } ,
564577 }
565578 } )
579+ . postProcessSnapshot ( snap => {
580+ const {
581+ rowHeight,
582+ rowProportion,
583+ showAllLetters,
584+ mismatchRendering,
585+ showBranchLen,
586+ treeAreaWidth,
587+ showAsUpperCase,
588+ showSidebar,
589+ ...rest
590+ } = snap as typeof snap & {
591+ rowHeight ?: number
592+ rowProportion ?: number
593+ showAllLetters ?: boolean
594+ mismatchRendering ?: boolean
595+ showBranchLen ?: boolean
596+ treeAreaWidth ?: number
597+ showAsUpperCase ?: boolean
598+ showSidebar ?: boolean
599+ }
600+ return {
601+ ...( rest as Omit < typeof rest , symbol > ) ,
602+ ...( rowHeight !== defaultRowHeight ? { rowHeight } : { } ) ,
603+ ...( rowProportion !== defaultRowProportion ? { rowProportion } : { } ) ,
604+ ...( showAllLetters !== defaultShowAllLetters ? { showAllLetters } : { } ) ,
605+ ...( mismatchRendering !== defaultMismatchRendering
606+ ? { mismatchRendering }
607+ : { } ) ,
608+ ...( showBranchLen !== defaultShowBranchLen ? { showBranchLen } : { } ) ,
609+ ...( treeAreaWidth !== defaultTreeAreaWidth ? { treeAreaWidth } : { } ) ,
610+ ...( showAsUpperCase !== defaultShowAsUpperCase
611+ ? { showAsUpperCase }
612+ : { } ) ,
613+ ...( showSidebar !== defaultShowSidebar ? { showSidebar } : { } ) ,
614+ }
615+ } )
566616}
567617
568618export type LinearMafDisplayStateModel = ReturnType < typeof stateModelFactory >
0 commit comments