make filters async
since most of its content is async anyway
This commit is contained in:
		
							parent
							
								
									532295a610
								
							
						
					
					
						commit
						b5c0f7ac68
					
				
					 1 changed files with 94 additions and 94 deletions
				
			
		|  | @ -10,7 +10,9 @@ export default class filters { | ||||||
| 				chrome.runtime.getURL("scripts/secretariat.js") | 				chrome.runtime.getURL("scripts/secretariat.js") | ||||||
| 			); | 			); | ||||||
| 			 | 			 | ||||||
| 			return ((await Promise.all([secretariat.read([`filters`], -1)]))[0]) | 			return(secretariat.read(`filters`, -1).then((filters) => { | ||||||
|  | 				return(filters) | ||||||
|  | 			})); | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -18,7 +20,7 @@ export default class filters { | ||||||
| 
 | 
 | ||||||
| 	@param {string} URL the current URL | 	@param {string} URL the current URL | ||||||
| 	*/ | 	*/ | ||||||
| 	static async select(URL = window.location.href) { | 	async select(URL = window.location.href) { | ||||||
| 		this.one = await (async () => { | 		this.one = await (async () => { | ||||||
| 			// Import the secretariat.
 | 			// Import the secretariat.
 | ||||||
| 			const secretariat = await import( | 			const secretariat = await import( | ||||||
|  | @ -40,8 +42,7 @@ export default class filters { | ||||||
| 	@param {string} URL the URL to update | 	@param {string} URL the URL to update | ||||||
| 	@return {boolean} the state | 	@return {boolean} the state | ||||||
| 	*/ | 	*/ | ||||||
| 	static update(URL) { | 	async update(URL) { | ||||||
| 		this.all = (async () => { |  | ||||||
| 		// Import the updater.
 | 		// Import the updater.
 | ||||||
| 		const secretariat = await import( | 		const secretariat = await import( | ||||||
| 			chrome.runtime.getURL("scripts/secretariat.js") | 			chrome.runtime.getURL("scripts/secretariat.js") | ||||||
|  | @ -113,7 +114,7 @@ export default class filters { | ||||||
| 						if (result) { | 						if (result) { | ||||||
| 							// Write the filter to storage.
 | 							// Write the filter to storage.
 | ||||||
| 							secretariat.write(["filters", filter_URL], result, -1); | 							secretariat.write(["filters", filter_URL], result, -1); | ||||||
| 								console.log( | 							alerts.log( | ||||||
| 								texts.localized( | 								texts.localized( | ||||||
| 									`settings_filters_update_status_complete`, | 									`settings_filters_update_status_complete`, | ||||||
| 									null, | 									null, | ||||||
|  | @ -125,7 +126,7 @@ export default class filters { | ||||||
| 					}) | 					}) | ||||||
| 					.catch((error) => { | 					.catch((error) => { | ||||||
| 						// Inform the user of the download failure.
 | 						// Inform the user of the download failure.
 | ||||||
| 							console.log( | 						alerts.error( | ||||||
| 							texts.localized( | 							texts.localized( | ||||||
| 								`settings_filters_update_status_failure`, | 								`settings_filters_update_status_failure`, | ||||||
| 								null, | 								null, | ||||||
|  | @ -140,9 +141,8 @@ export default class filters { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// Regardless of the download result, update will also mean setting the filters object to whatever is in storage. 
 | 		// Regardless of the download result, update will also mean setting the filters object to whatever is in storage. 
 | ||||||
| 			return(secretariat.read(`filters`, -1).then((filters) => { | 		this.all = (await secretariat.read(`filters`, -1));	 | ||||||
| 				return(filters) | 
 | ||||||
| 			})); | 		return(this.all); | ||||||
| 		})(); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue