mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-07 09:55:43 -04:00
fix: catch access forbidden errors for local storage access
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
be3ca5cdeb
commit
ce286cc092
2 changed files with 27 additions and 8 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue