Storage-Info hinzugefügt
This commit is contained in:
@@ -535,6 +535,44 @@ InitPromise.addPromise(() => {
|
||||
// window["soundManagerInstance"]["resumeAllIfNotMuted"] = window["soundManagerInstance"].resumeAllIfNotMuted;
|
||||
// });
|
||||
|
||||
class StorageManager {
|
||||
static getInstance() {
|
||||
if (Helper.isNull(StorageManager.instance)) {
|
||||
StorageManager.instance = new StorageManager();
|
||||
}
|
||||
return StorageManager.instance;
|
||||
}
|
||||
|
||||
async estimate() {
|
||||
if ('storage' in navigator && 'estimate' in navigator.storage) {
|
||||
// We've got the real thing! Return its response.
|
||||
return navigator.storage.estimate();
|
||||
}
|
||||
|
||||
if ('webkitTemporaryStorage' in navigator &&
|
||||
'queryUsageAndQuota' in navigator.webkitTemporaryStorage) {
|
||||
// Return a promise-based wrapper that will follow the expected interface.
|
||||
return new Promise(function (resolve, reject) {
|
||||
navigator.webkitTemporaryStorage.queryUsageAndQuota(
|
||||
function (usage, quota) {
|
||||
resolve({usage: usage, quota: quota});
|
||||
},
|
||||
reject
|
||||
);
|
||||
});
|
||||
}
|
||||
// If we can't estimate the values, return a Promise that resolves with NaN.
|
||||
return Promise.resolve({usage: NaN, quota: NaN});
|
||||
}
|
||||
|
||||
canEstimateStorage() {
|
||||
return ('storage' in navigator && 'estimate' in navigator.storage || 'webkitTemporaryStorage' in navigator &&
|
||||
'queryUsageAndQuota' in navigator.webkitTemporaryStorage);
|
||||
}
|
||||
}
|
||||
|
||||
StorageManager.instance = null;
|
||||
|
||||
class TabbedFragment extends Fragment {
|
||||
constructor(site) {
|
||||
super(site, 'pwaAssets/html/fragment/tabbedFragment.html');
|
||||
@@ -600,4 +638,4 @@ class TabbedFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
export { DelayPromise, InstallManager, Matomo, MatomoShareButton, RotateHelper, ScaleHelper, AudioChain, SoundManager, TabbedFragment };
|
||||
export { DelayPromise, InstallManager, Matomo, MatomoShareButton, RotateHelper, ScaleHelper, AudioChain, SoundManager, StorageManager, TabbedFragment };
|
||||
|
||||
Reference in New Issue
Block a user