Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add a 'Clear Cache' button #708

Merged
merged 2 commits into from
Feb 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/components/structures/UserSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ module.exports = React.createClass({
Modal.createDialog(BugReportDialog, {});
},

_onClearCacheClicked: function() {
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);
});
},

_onInviteStateChange: function(event, member, oldMembership) {
if (member.userId === this._me && oldMembership === "invite") {
this.forceUpdate();
Expand Down Expand Up @@ -690,6 +698,18 @@ module.exports = React.createClass({
</div>;
},

_renderClearCache: function() {
return <div>
<h3>Clear Cache</h3>
<div className="mx_UserSettings_section">
<AccessibleButton className="mx_UserSettings_button danger"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How dangerous is it to go alone clear the cache?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You made a Zelda reference! /me swoons

It's deleting data, which I think is dangerous, and it will cause a long resync potentially which is bad. I don't have any strong feelings either way.

onClick={this._onClearCacheClicked}>
Clear Cache and Reload
</AccessibleButton>
</div>
</div>;
},

_renderBulkOptions: function() {
let invitedRooms = MatrixClientPeg.get().getRooms().filter((r) => {
return r.hasMembershipState(this._me, "invite");
Expand Down Expand Up @@ -913,6 +933,8 @@ module.exports = React.createClass({
</div>
</div>

{this._renderClearCache()}

{this._renderDeactivateAccount()}

</GeminiScrollbar>
Expand Down