From a5351f673a47a28c010fdc9dc4b92878a5f0098c Mon Sep 17 00:00:00 2001 From: turner Date: Wed, 1 Nov 2023 15:17:51 -0400 Subject: [PATCH] Add genome change listener to igvConfig --- js/app.js | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/js/app.js b/js/app.js index d7fdcdd..433e339 100644 --- a/js/app.js +++ b/js/app.js @@ -106,6 +106,28 @@ async function main(container, config) { } } + igvConfig.listeners = { + + 'genomechange': async ({genome, trackConfigurations}) => { + + if (currentGenomeId !== genome.id) { + + currentGenomeId = genome.id + + let configs = await getPathsWithTrackRegistryFile(genome.id, config.trackRegistryFile) + + if (undefined === configs) { + configs = trackConfigurations + } + + if (configs) { + await updateTrackMenusWithTrackConfigurations(genome.id, undefined, configs, $('#igv-app-track-dropdown-menu')) + } + + } + } + } + const browser = await igv.createBrowser(container, igvConfig) if (browser) { @@ -306,27 +328,6 @@ async function initializationHelper(browser, container, options) { } - browser.on('genomechange', async ({genome, trackConfigurations}) => { - - if (currentGenomeId !== genome.id) { - - currentGenomeId = genome.id - - let configs = await getPathsWithTrackRegistryFile(genome.id, options.trackRegistryFile) - - if (undefined === configs) { - configs = trackConfigurations - } - - if (configs) { - await updateTrackMenusWithTrackConfigurations(genome.id, undefined, configs, $('#igv-app-track-dropdown-menu')) - } - - } - } - ) - - browser.fireEvent('genomechange', [ { genome: browser.genome, trackConfigurations: undefined } ]) } async function updateTrackMenusWithTrackHub(hub) {