Prevent embeds from breaking in Chrome incognito (#814)

This commit is contained in:
Austin Chen 2022-08-28 22:40:57 -07:00 committed by GitHub
parent 7ea6777d6b
commit 8f338a8d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,15 @@ import { useStateCheckEquality } from 'web/hooks/use-state-check-equality'
type AuthUser = undefined | null | UserAndPrivateUser
const CACHED_USER_KEY = 'CACHED_USER_KEY_V2'
// Proxy localStorage in case it's not available (eg in incognito iframe)
const localStorage =
typeof window !== 'undefined'
? window.localStorage
: {
getItem: () => null,
setItem: () => {},
removeItem: () => {},
}
const ensureDeviceToken = () => {
let deviceToken = localStorage.getItem('device-token')