diff --git a/home_page.js b/home_page.js index d37e921..77bc4b6 100644 --- a/home_page.js +++ b/home_page.js @@ -1,4 +1,4 @@ -import { commonCss } from './lib/iobio-charts/common.js'; +import { commonCss, getDataBroker } from './lib/iobio-charts/common.js'; import { navigateTo } from './router.js'; import { URLInputModal } from './url_input_modal.js'; import { LocalFileInputModal } from './local_file_input_modal.js'; @@ -166,6 +166,8 @@ class HomePage extends HTMLElement { this.attachShadow({ mode: 'open' }); this.shadowRoot.appendChild(homePageTemplate.content.cloneNode(true)); this.initDOMElements(); + + this.currentAlignmentUrl = null; } initDOMElements() { @@ -178,6 +180,8 @@ class HomePage extends HTMLElement { } connectedCallback() { + this.broker = getDataBroker(this); + this.localFileButton.addEventListener('click', () => this.localFileInputModal.showModal()); // Handle the custom event from the local-file-input-modal this.localFileInputModal.addEventListener('local-file-loaded', async (event) => this.handleLocalFileLoaded(event)); @@ -229,6 +233,12 @@ class HomePage extends HTMLElement { // Navigate to the main content page with the URLs navigateToMainContent(url1, url2) { + if (url1 !== this.currentAlignmentUrl) { + this.currentAlignmentUrl = url1; + // reset the state + this.broker.reset(); + } + const queryParams = new URLSearchParams({ 'alignment-url': url1, });