Skip to content

Commit

Permalink
feat: handle safari popup limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Oct 28, 2024
1 parent 06cc389 commit 7ab7e1a
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions packages/frontend/core/src/components/affine/auth/oauth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,28 @@ function OAuthProvider({ provider, redirectUrl }: OAuthProviderProps) {
const onClick = useCallback(() => {
async function preflight() {
if (ignore) return;
const url = await auth.oauthPreflight(
provider,
appInfo?.schema,
false,
redirectUrl
);
if (!ignore) {
popupWindow(url);
try {
return await auth.oauthPreflight(
provider,
appInfo?.schema,
false,
redirectUrl
);
} catch {
return null;
}
}

let ignore = false;
// eslint-disable-next-line @typescript-eslint/no-floating-promises
preflight();
preflight().then(url => {
// cover popup limit in safari
setTimeout(() => {
if (url && !ignore) {
popupWindow(url);
}
});
});
return () => {
ignore = true;
};
Expand Down

0 comments on commit 7ab7e1a

Please sign in to comment.