@@ -29,6 +29,7 @@ let ports: { [key: number]: Runtime.Port } = {};
2929const responseMap : Map < string , { server : RequestInfo , response : IMAGEResponse , request : IMAGERequest } > = new Map ( ) ;
3030var serverUrl : RequestInfo ;
3131var renderingsPanel : browser . Windows . Window | browser . Tabs . Tab ;
32+ var errorPanel : browser . Windows . Window | browser . Tabs . Tab ;
3233let launchPad : browser . Windows . Window | browser . Tabs . Tab ;
3334var graphicUrl : string = "" ;
3435var extVersion = process . env . NODE_ENV ;
@@ -197,13 +198,15 @@ async function handleMessage(p: Runtime.Port, message: any) {
197198 "body" : JSON . stringify ( query )
198199 } ) ;
199200 windowsPanel ? browser . windows . remove ( progressWindow . id ! ) : browser . tabs . remove ( progressWindow . id ! ) ;
201+ // close existing error panel if it exists
202+ windowsPanel ? ( errorPanel && browser . windows . remove ( errorPanel . id ! ) ) : ( errorPanel && browser . tabs . remove ( errorPanel . id ! ) ) ;
200203 if ( resp . ok ) {
201204 json = await resp . json ( ) ;
202205 } else {
203- windowsPanel ? browser . windows . create ( {
206+ errorPanel = windowsPanel ? await browser . windows . create ( {
204207 type : "panel" ,
205208 url : "errors/http_error.html"
206- } ) : browser . tabs . create ( {
209+ } ) : await browser . tabs . create ( {
207210 url : "errors/http_error.html" ,
208211 } ) ;
209212 console . error ( `HTTP Error ${ resp . status } : ${ resp . statusText } ` ) ;
@@ -213,10 +216,12 @@ async function handleMessage(p: Runtime.Port, message: any) {
213216 }
214217 } catch {
215218 windowsPanel ? browser . windows . remove ( progressWindow . id ! ) : browser . tabs . remove ( progressWindow . id ! ) ;
216- windowsPanel ? browser . windows . create ( {
219+ // close existing error panel if it exists
220+ windowsPanel ? ( errorPanel && browser . windows . remove ( errorPanel . id ! ) ) : ( errorPanel && browser . tabs . remove ( errorPanel . id ! ) ) ;
221+ errorPanel = windowsPanel ? await browser . windows . create ( {
217222 type : "panel" ,
218223 url : "errors/http_error.html"
219- } ) : browser . tabs . create ( {
224+ } ) : await browser . tabs . create ( {
220225 url : "errors/http_error.html" ,
221226 } ) ;
222227 return ;
@@ -811,6 +816,7 @@ browser.contextMenus.onClicked.addListener((info, tab) => {
811816 }
812817 } else {
813818 console . error ( "No tab passed to context menu listener!" ) ;
819+ windowsPanel ? ( errorPanel && browser . windows . remove ( errorPanel . id ! ) ) : ( errorPanel && browser . tabs . remove ( errorPanel . id ! ) ) ;
814820 windowsPanel ? browser . windows . create ( {
815821 type : "panel" ,
816822 url : "errors/http_error.html"
0 commit comments