Skip to content

Commit

Permalink
Fix requestStorageAccess() rejection handling
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Jul 30, 2022
1 parent 081bd66 commit 48964d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export async function hasStorageAccess() {
// accessing localStorage may be forbidden.
if (typeof document.hasStorageAccess === 'undefined') return true;
if (await document.hasStorageAccess()) return true;
await document.requestStorageAccess();
try {
await document.requestStorageAccess();
} catch (err) {
// The request can only be made under very specific conditions.
}
return await document.hasStorageAccess();
}

1 comment on commit 48964d5

@vercel
Copy link

@vercel vercel bot commented on 48964d5 Jul 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.