Skip to content

Commit

Permalink
Fix persistent storage warning alert
Browse files Browse the repository at this point in the history
  • Loading branch information
lmg-anon committed Dec 20, 2024
1 parent 80ce958 commit 96e427a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions mikupad.html
Original file line number Diff line number Diff line change
Expand Up @@ -4781,17 +4781,15 @@
const persistent = await navigator.storage.persist();
const elapsedTime = performance.now() - startTime;

if (!persistent) {
// If the response came back in less than 200ms, it was likely an automatic denial
// (200ms is generally considered faster than human reaction time)
if (elapsedTime < 200) {
if (!localStorage.getItem('persistentStorageWarningShown')) {
alert('Your browser has automatically denied persistent storage for Mikupad. Be aware that the browser may clear the database when under storage pressure. You might need to adjust your browser settings to enable this feature, or alternatively, you can use the Mikupad server.');
localStorage.setItem('persistentStorageWarningShown', 'true');
}
if (!persistent && !localStorage.getItem('persistentStorageWarningShown')) {
// If the response came back in less than 500ms, it was likely an automatic denial
// (500ms is generally considered faster than human reaction time)
if (elapsedTime < 500) {
alert('Your browser has automatically denied persistent storage for Mikupad. Be aware that the browser may clear the database when under storage pressure. You might need to adjust your browser settings to enable this feature, or alternatively, you can use the Mikupad server.');
} else {
alert('You have chosen not to enable persistent storage for Mikupad. Be aware that the browser may clear the database when under storage pressure. As an optional alternative, you can use the Mikupad server.');
}
localStorage.setItem('persistentStorageWarningShown', 'true');
}
}
} catch {}
Expand Down

0 comments on commit 96e427a

Please sign in to comment.