Merge pull request #4092 from matrix-org/t3chguy/persist
Use Persistent Storage where possible
This commit is contained in:
commit
b1a3d8ad63
3 changed files with 32 additions and 0 deletions
|
@ -65,6 +65,7 @@ import { ThemeWatcher } from "../../theme";
|
|||
import { storeRoomAliasInCache } from '../../RoomAliasCache';
|
||||
import { defer } from "../../utils/promise";
|
||||
import ToastStore from "../../stores/ToastStore";
|
||||
import * as StorageManager from "../../utils/StorageManager";
|
||||
|
||||
/** constants for MatrixChat.state.view */
|
||||
export const VIEWS = {
|
||||
|
@ -1193,6 +1194,8 @@ export default createReactClass({
|
|||
} else {
|
||||
this._showScreenAfterLogin();
|
||||
}
|
||||
|
||||
StorageManager.tryPersistStorage();
|
||||
},
|
||||
|
||||
_showScreenAfterLogin: function() {
|
||||
|
|
|
@ -106,6 +106,25 @@ export default async function sendBugReport(bugReportEndpoint, opts) {
|
|||
body.append('enabled_labs', enabledLabs.join(', '));
|
||||
}
|
||||
|
||||
// add storage persistence/quota information
|
||||
if (navigator.storage && navigator.storage.persisted) {
|
||||
try {
|
||||
body.append("storageManager_persisted", await navigator.storage.persisted());
|
||||
} catch (e) {}
|
||||
}
|
||||
if (navigator.storage && navigator.storage.estimate) {
|
||||
try {
|
||||
const estimate = await navigator.storage.estimate();
|
||||
body.append("storageManager_quota", estimate.quota);
|
||||
body.append("storageManager_usage", estimate.usage);
|
||||
if (estimate.usageDetails) {
|
||||
Object.keys(estimate.usageDetails).forEach(k => {
|
||||
body.append(`storageManager_usage_${k}`, estimate.usageDetails[k]);
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
if (opts.sendLogs) {
|
||||
progressCallback(_t("Collecting logs"));
|
||||
const logs = await rageshake.getLogsForReport();
|
||||
|
|
|
@ -43,6 +43,16 @@ function track(action) {
|
|||
Analytics.trackEvent("StorageManager", action);
|
||||
}
|
||||
|
||||
export function tryPersistStorage() {
|
||||
if (navigator.storage && navigator.storage.persist) {
|
||||
navigator.storage.persist().then(persistent => {
|
||||
console.log("StorageManager: Persistent?", persistent);
|
||||
});
|
||||
} else {
|
||||
console.log("StorageManager: Persistence unsupported");
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkConsistency() {
|
||||
log("Checking storage consistency");
|
||||
log(`Local storage supported? ${!!localStorage}`);
|
||||
|
|
Loading…
Reference in a new issue