@@ -36,21 +36,20 @@ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
3636import { lastValueFrom } from 'rxjs' ;
3737
3838const VariantTableWidget = observer ( props => {
39- const { assembly, trackId, parsedLocString, sessionId, session, pluginManager } = props
40- const { assemblyNames, assemblyManager } = session
41- const { view } = session
42-
43- // The code expects a proper GUID, yet the trackId is a string containing the GUID + filename
44- const trackGUID = truncateToValidGUID ( props . trackId )
45-
46- // NOTE: since the trackId is GUID+filename, allow exact string matching, or a match on the GUID portion alone.
47- // Upstream code might only have access to the GUID and translating to the trackId isnt always easy
48- const track = view . tracks . find (
49- t => t . configuration . trackId === trackId || truncateToValidGUID ( t . configuration . trackId ) . toUpperCase ( ) === trackGUID . toUpperCase ( )
50- )
51-
52- if ( ! track ) {
53- return ( < p > Unknown track: { trackId } </ p > )
39+ const { assembly, trackId, parsedLocString, sessionId, session, pluginManager } = props ;
40+ const { assemblyNames = [ ] , assemblyManager } = session ?? { } ;
41+ const { view } = session ?? { } ;
42+
43+ var track = undefined ;
44+ var trackGUID = undefined ;
45+ if ( view && trackId ) {
46+ // The code expects a proper GUID, yet the trackId is a string containing the GUID + filename
47+ // NOTE: since the trackId is GUID+filename, allow exact string matching, or a match on the GUID portion alone.
48+ // Upstream code might only have access to the GUID and translating to the trackId isnt always easy
49+ trackGUID = truncateToValidGUID ( props . trackId )
50+ track = view . tracks . find (
51+ t => t . configuration . trackId === trackId || truncateToValidGUID ( t . configuration . trackId ) . toUpperCase ( ) === trackGUID . toUpperCase ( )
52+ )
5453 }
5554
5655 function handleSearch ( data ) {
@@ -150,7 +149,6 @@ const VariantTableWidget = observer(props => {
150149 < span className = 'table-cell-truncate' > { displayValue } </ span >
151150 </ Typography >
152151 { renderPopover &&
153- // TODO
154152 < Popover
155153 id = "mouse-over-popover"
156154 open = { open }
@@ -236,7 +234,7 @@ const VariantTableWidget = observer(props => {
236234 const [ activeWidgetList , setActiveWidgetList ] = useState < string [ ] > ( [ ] )
237235
238236 // False until initial data load or an error:
239- const [ dataLoaded , setDataLoaded ] = useState ( ! parsedLocString )
237+ const [ dataLoaded , setDataLoaded ] = useState ( false )
240238
241239 const urlParams = new URLSearchParams ( window . location . search ) ;
242240 const page = parseInt ( urlParams . get ( 'page' ) || '0' ) ;
@@ -278,20 +276,15 @@ const VariantTableWidget = observer(props => {
278276 } )
279277 }
280278
281- fetch ( )
279+ if ( sessionId && trackGUID ) {
280+ fetch ( )
281+ }
282+
282283 return ( ) => {
283284 window . removeEventListener ( 'popstate' , handlePopState ) ;
284285 } ;
285286
286- } , [ pluginManager , parsedLocString , session . visibleWidget ] )
287-
288- if ( ! view ) {
289- return
290- }
291-
292- if ( ! track ) {
293- return ( < p > Unable to find track: { trackId } </ p > )
294- }
287+ } , [ pluginManager , parsedLocString , session ?. visibleWidget , sessionId , trackGUID ] )
295288
296289 if ( error ) {
297290 throw new Error ( error )
@@ -435,7 +428,7 @@ const VariantTableWidget = observer(props => {
435428 < LoadingIndicator isOpen = { ! dataLoaded } />
436429
437430 {
438- [ ...session . activeWidgets ] . map ( ( elem ) => {
431+ [ ...( session ? .activeWidgets ?? [ ] ) ] . map ( ( elem ) => {
439432 const widget = elem [ 1 ]
440433 const widgetType = pluginManager . getWidgetType ( widget . type )
441434 const { ReactComponent } = widgetType
0 commit comments