Browse Source

Test if navigator.storage is present before using it (#7460)

pull/4/head
Akihiko Odaki 6 years ago
committed by Eugen Rochko
parent
commit
f1ed855f96
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      app/javascript/mastodon/storage/modifier.js

+ 3
- 1
app/javascript/mastodon/storage/modifier.js View File

@ -182,7 +182,9 @@ export function putStatuses(records) {
}
export function freeStorage() {
return navigator.storage.estimate().then(({ quota, usage }) => {
// navigator.storage is not present on:
// Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.100 Safari/537.36 Edge/16.16299
return 'storage' in navigator && navigator.storage.estimate().then(({ quota, usage }) => {
if (usage + storageMargin < quota) {
return null;
}

Loading…
Cancel
Save