attempt to deactivate the window when it ceases to exist
Prevent errors when re-opening
This commit is contained in:
		
							parent
							
								
									c9f4707e09
								
							
						
					
					
						commit
						5098e733eb
					
				
					 1 changed files with 18 additions and 11 deletions
				
			
		|  | @ -15,15 +15,22 @@ export default class Window { | ||||||
| 	Check this window's state.  | 	Check this window's state.  | ||||||
| 	*/ | 	*/ | ||||||
| 	#check() { | 	#check() { | ||||||
|  | 		const deactivate = () => { | ||||||
|  | 			delete this.ID; | ||||||
|  | 			this.hidden = true; | ||||||
|  | 		}; | ||||||
|  | 
 | ||||||
| 		// Determine if this window is still open. 
 | 		// Determine if this window is still open. 
 | ||||||
| 		(this.ID) | 		try { | ||||||
| 			? chrome.windows.get(this.ID, (window) => { | 			(this.ID) | ||||||
| 				if (window == null) { | 				? chrome.windows.get(this.ID, (window) => { | ||||||
| 					delete this.ID; | 					(window == null) ? deactivate() : false; | ||||||
| 					this.hidden = true; | 				}) | ||||||
| 				} | 				: false; | ||||||
| 			}) | 		} catch(err) { | ||||||
| 			: false; | 			deactivate(); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* | 	/* | ||||||
|  | @ -32,12 +39,12 @@ export default class Window { | ||||||
| 	show() { | 	show() { | ||||||
| 		this.#check(); | 		this.#check(); | ||||||
| 
 | 
 | ||||||
| 		(this.hidden || this.hidden == null || !(this.ID)) | 		if (!this.ID) { | ||||||
| 			? chrome.windows.create(this.#options, (window) => { | 			chrome.windows.create(this.#options, (window) => { | ||||||
| 				this.hidden = false; | 				this.hidden = false; | ||||||
| 				this.ID = window.id; | 				this.ID = window.id; | ||||||
| 			}) | 			}) | ||||||
| 			: false; | 		}; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue