Skip to content

Commit

Permalink
Add genome change listener to igvConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Nov 1, 2023
1 parent 7b8d0ec commit a5351f6
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a5351f6

Please sign in to comment.