c2587413555c7cabd82b21c578d5a6f99599e7d7 jrobinso Tue Sep 16 09:45:03 2025 -0700 Bug -- missing await diff --git src/hg/js/igvFileHelper.js src/hg/js/igvFileHelper.js index 1184fe71ab9..3b230f51099 100644 --- src/hg/js/igvFileHelper.js +++ src/hg/js/igvFileHelper.js @@ -87,31 +87,31 @@ const igvSession = JSON.parse(igv.uncompressSession(`blob:${sessionString}`)); // Reconnect any file-based tracks to the actual File objects. if (igvSession.tracks) { const failed = await restoreTrackConfigurations(igvSession.tracks); if (failed.length > 0) { const sendRestoreRequest = () => channel.postMessage({type: "restoreFiles", files: failed}); if (filePicker && !filePicker.closed) { sendRestoreRequest(); return; - } else if (pingFilePicker()) { + } else if (await pingFilePicker()) { // A file picker is open, but (apparently) doesn't have references to the requested files. // Send a request to restore the files, which will bring the file picker to the front and // prompt the user to select the files. sendRestoreRequest(); } else { // Open a file picker and prompt user to select files to restore the connections. filePicker = openFilePicker(); filePicker.onload = () => { channel.postMessage({type: "restoreFiles", files: failed}); }; } } @@ -356,43 +356,43 @@ // simulate UCSC browser session handling. // XX TODO - not enough time for sending an HTTP request to update cart - need a better system! // document.onvisibilitychange = () => { // if (document.visibilityState === "hidden") { // if (igvBrowser) { // //setCartVar("igvState", igvSession, null, false); // //const igvSession = igvBrowser.compressedSession(); // //localStorage.setItem("igvSession", igvSession); // } // } // }; // The "Add IGV track" button handler. The button opens the file picker window, unless // it is already open in which case it brings that window to the front. Tracks are added // from the filePicker page by selecting track files. - window.addEventListener("DOMContentLoaded", () => { + window.addEventListener("DOMContentLoaded", async () => { document.getElementById('hgtIgv').addEventListener('click', async function (e) { e.preventDefault(); // our if (filePicker && !filePicker.closed) { filePicker.focus(); return; } else { // A filePicker might be open from a previous instance of this page. We can detect this by sending // a message on the channel and waiting briefly for a response, but we cannot get a reference to the window // so we ask the user to bring it to the front. - const responded = await pingFilePicker(channel); + const responded = await pingFilePicker(); if (responded) { alert("File picker is already open. Please switch to that window."); } else { // No filePicker found, open a new one. filePicker = openFilePicker(); } } }); }); /** * Send a "ping" message to the file picker window and wait up to 100 msec for a "pong" response. Used to * determine if a file picker window is already open. * @param channel