-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1135 from geyserfund/hot-fix/geyser-reload-safari
Hot-fix/geyser-reload-safari
- Loading branch information
Showing
4 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { DateTime } from 'luxon' | ||
|
||
const CHUNK_LOAD_ERROR = 'ChunkLoadError' | ||
const LOCAL_STORAGE_LAST_REFRESH_KEY = 'ChunkLoadError' | ||
const ONE_MINUTE_IN_MILIS = 60 * 1000 | ||
|
||
export const handleAssetLoadError = (e: any) => { | ||
if (e?.name && e.name === CHUNK_LOAD_ERROR) { | ||
const refreshed = getRefreshStateFromLocalStorage() | ||
if (!refreshed) { | ||
storeRateToLocalStorage() | ||
window.location.reload() | ||
} | ||
} | ||
|
||
return {} as any | ||
} | ||
|
||
const getRefreshStateFromLocalStorage = () => { | ||
const values = localStorage.getItem(LOCAL_STORAGE_LAST_REFRESH_KEY) | ||
const timeLineMilis = values ? Number(values) : 0 | ||
const now = DateTime.local().toMillis() | ||
|
||
let refreshed = false | ||
|
||
if (timeLineMilis && now - timeLineMilis < ONE_MINUTE_IN_MILIS) { | ||
refreshed = true | ||
} | ||
|
||
return refreshed | ||
} | ||
|
||
const storeRateToLocalStorage = () => { | ||
const newDate = DateTime.local().toMillis() | ||
|
||
localStorage.setItem(LOCAL_STORAGE_LAST_REFRESH_KEY, `${newDate}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './computeBadges' | ||
export * from './fundingCalculation' | ||
export * from './getAvatarMetadata' | ||
export * from './handleAssetLoadError' | ||
export * from './ScrollInvoke' | ||
export * from './useBTCConverter' |