From 0a31efa0b7cb845a1940b7a4ae36a674fa89417a Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 17 Feb 2017 15:16:28 +0000 Subject: [PATCH 1/2] Add a 'Clear Cache' button This deletes the IndexedDB database and reloads the page. This solely exists as a get-out clause for users in case the indexedDB instance gets corrupted. Hopefully we won't ever need to point users to it. --- src/components/structures/UserSettings.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index f8240e247b..b928243d40 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -418,6 +418,14 @@ module.exports = React.createClass({ Modal.createDialog(BugReportDialog, {}); }, + _onClearCacheClicked: function() { + MatrixClientPeg.get().store.deleteAllData().then(() => { + // forceReload=false since we don't really need new HTML/JS files + // we just need to restart the JS runtime. + window.location.reload(false); + }); + }, + _onInviteStateChange: function(event, member, oldMembership) { if (member.userId === this._me && oldMembership === "invite") { this.forceUpdate(); @@ -690,6 +698,18 @@ module.exports = React.createClass({ ; }, + _renderClearCache: function() { + return
+

Clear Cache

+
+ + Clear Cache (triggers page refresh) + +
+
; + }, + _renderBulkOptions: function() { let invitedRooms = MatrixClientPeg.get().getRooms().filter((r) => { return r.hasMembershipState(this._me, "invite"); @@ -913,6 +933,8 @@ module.exports = React.createClass({ + {this._renderClearCache()} + {this._renderDeactivateAccount()} From 8d6c3cd3f45909baad3fa1e29a4a2ab71c5f33d3 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 17 Feb 2017 15:37:49 +0000 Subject: [PATCH 2/2] Review comments --- src/components/structures/UserSettings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index b928243d40..faa8a56894 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -419,7 +419,7 @@ module.exports = React.createClass({ }, _onClearCacheClicked: function() { - MatrixClientPeg.get().store.deleteAllData().then(() => { + MatrixClientPeg.get().store.deleteAllData().done(() => { // forceReload=false since we don't really need new HTML/JS files // we just need to restart the JS runtime. window.location.reload(false); @@ -704,7 +704,7 @@ module.exports = React.createClass({
- Clear Cache (triggers page refresh) + Clear Cache and Reload
;