@@ -30,6 +30,7 @@ import { AnalysisResults } from './shared/analysis-result';
3030export class RemoteQueriesInterfaceManager {
3131 private panel : WebviewPanel | undefined ;
3232 private panelLoaded = false ;
33+ private currentQueryId : string | undefined ;
3334 private panelLoadedCallBacks : ( ( ) => void ) [ ] = [ ] ;
3435
3536 constructor (
@@ -47,6 +48,8 @@ export class RemoteQueriesInterfaceManager {
4748
4849 await this . waitForPanelLoaded ( ) ;
4950 const model = this . buildViewModel ( query , queryResult ) ;
51+ this . currentQueryId = queryResult . queryId ;
52+
5053 await this . postMessage ( {
5154 t : 'setRemoteQueryResult' ,
5255 queryResult : model
@@ -55,7 +58,7 @@ export class RemoteQueriesInterfaceManager {
5558 // Ensure all pre-downloaded artifacts are loaded into memory
5659 await this . analysesResultsManager . loadDownloadedAnalyses ( model . analysisSummaries ) ;
5760
58- await this . setAnalysisResults ( this . analysesResultsManager . getAnalysesResults ( queryResult . queryId ) ) ;
61+ await this . setAnalysisResults ( this . analysesResultsManager . getAnalysesResults ( queryResult . queryId ) , queryResult . queryId ) ;
5962 }
6063
6164 /**
@@ -111,6 +114,7 @@ export class RemoteQueriesInterfaceManager {
111114 this . panel . onDidDispose (
112115 ( ) => {
113116 this . panel = undefined ;
117+ this . currentQueryId = undefined ;
114118 } ,
115119 null ,
116120 ctx . subscriptions
@@ -212,23 +216,25 @@ export class RemoteQueriesInterfaceManager {
212216 }
213217
214218 private async downloadAnalysisResults ( msg : RemoteQueryDownloadAnalysisResultsMessage ) : Promise < void > {
219+ const queryId = this . currentQueryId ;
215220 await this . analysesResultsManager . downloadAnalysisResults (
216221 msg . analysisSummary ,
217- results => this . setAnalysisResults ( results ) ) ;
222+ results => this . setAnalysisResults ( results , queryId ) ) ;
218223 }
219224
220225 private async downloadAllAnalysesResults ( msg : RemoteQueryDownloadAllAnalysesResultsMessage ) : Promise < void > {
226+ const queryId = this . currentQueryId ;
221227 await this . analysesResultsManager . loadAnalysesResults (
222228 msg . analysisSummaries ,
223229 undefined ,
224- results => this . setAnalysisResults ( results ) ) ;
230+ results => this . setAnalysisResults ( results , queryId ) ) ;
225231 }
226232
227- public async setAnalysisResults ( analysesResults : AnalysisResults [ ] ) : Promise < void > {
228- if ( this . panel ?. active ) {
233+ public async setAnalysisResults ( analysesResults : AnalysisResults [ ] , queryId : string | undefined ) : Promise < void > {
234+ if ( this . panel ?. active && this . currentQueryId === queryId ) {
229235 await this . postMessage ( {
230236 t : 'setAnalysesResults' ,
231- analysesResults : analysesResults
237+ analysesResults
232238 } ) ;
233239 }
234240 }
0 commit comments