Skip to content

Commit

Permalink
fix: try to fix the white screen issue in iOS WebView.
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Sep 24, 2024
1 parent 0219b1d commit 2edab85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { ErrorLogs, toastRun } from '$lib/stores/toast'
import { sleep } from '$lib/utils/helper'
import { md } from '$lib/utils/markdown'
import { isNotificationSupported } from '$lib/utils/window'
import {
myMessageStateAsync,
toDisplayUserInfo,
Expand Down Expand Up @@ -51,7 +52,8 @@
let userInfo: Readable<UserInfo & ProfileInfo>
let myInfo: Readable<(UserInfo & ProfileInfo) | null>
let grantedNotification = Notification.permission === 'granted'
let grantedNotification =
isNotificationSupported && Notification.permission === 'granted'
let displayDebug = false
async function loadMyFollowing() {
Expand Down
4 changes: 3 additions & 1 deletion src/ic_panda_frontend/src/lib/services/notification.sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export async function notifyd() {
console.log('Notification service started')
while (true) {
const identity =
Notification.permission === 'granted' && (await loadIdentity())
'Notification' in globalThis &&
Notification.permission === 'granted' &&
(await loadIdentity())
if (identity) {
const now = Date.now()
await tryRun(async () => {
Expand Down
2 changes: 2 additions & 0 deletions src/ic_panda_frontend/src/lib/utils/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const STR_UNDEFINED = 'undefined'
// NOTE: Use the function to guarantee it's re-evaluated between jsdom and node runtime for tests.
export const isWindowDefined = typeof window != STR_UNDEFINED
export const isDocumentDefined = typeof document != STR_UNDEFINED
export const isNotificationSupported =
isWindowDefined && 'Notification' in window
export const hasRequestAnimationFrame = () =>
isWindowDefined && typeof window['requestAnimationFrame'] != STR_UNDEFINED
export const noop = () => {}
Expand Down

0 comments on commit 2edab85

Please sign in to comment.