fix: catch access forbidden errors for local storage access

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-10-09 07:09:13 +02:00
parent be3ca5cdeb
commit ce286cc092
2 changed files with 27 additions and 8 deletions

View file

@ -17,18 +17,25 @@ const logger = new Logger('Application Loader')
* Create a custom delay in the loading of the application.
*/
const customDelay: () => Promise<void> = async () => {
if (
(isDevMode || isTestMode) &&
typeof window !== 'undefined' &&
typeof window.localStorage !== 'undefined' &&
(window.location.search.startsWith('?customDelay=') || window.localStorage.getItem('customDelay'))
) {
if ((isDevMode || isTestMode) && (window.location.search.startsWith('?customDelay=') || isCustomDelayActive())) {
return new Promise((resolve) => setTimeout(resolve, 500000000))
} else {
return Promise.resolve()
}
}
const isCustomDelayActive = (): boolean => {
try {
return (
typeof window !== 'undefined' &&
typeof window.localStorage !== 'undefined' &&
window.localStorage.getItem('customDelay') !== null
)
} catch {
return false
}
}
export interface InitTask {
name: string
task: () => Promise<void>