-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Safari specific handling in triggerAsyncCallback
- Loading branch information
Showing
1 changed file
with
6 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 6 additions & 1 deletion
7
packages/shared/src/services/submitPrompt/utils/triggerAsyncCallback.ts
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,6 +1,11 @@ | ||
import {CallbackFunction} from '../../../types/callbackFunction'; | ||
|
||
export const triggerAsyncCallback = (trigger: CallbackFunction, delay: number = 10) => { | ||
const isHighPerfJsEngine = navigator?.userAgent?.includes('Safari'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
salmenus
Author
Member
|
||
|
||
// TODO: To be replaced with a pure React implementation for submitPrompt that relies on React rendering cycle | ||
const defaultAsyncDelay: 1 | 10 = isHighPerfJsEngine ? 10 : 1; // Efficient async scheduling for Safari | ||
|
||
export const triggerAsyncCallback = (trigger: CallbackFunction, delay: number = defaultAsyncDelay) => { | ||
setTimeout(() => { | ||
trigger(); | ||
}, delay); | ||
|
This causes an error in Next.js server-side:
ReferenceError: navigator is not defined
@salmenus