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

Commit a471482

Browse files
authored
Hide clear cache and reload button if crash is before client init (#7242)
1 parent 5ba2d16 commit a471482

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/components/structures/LoggedInView.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ interface IState {
138138
* This is what our MatrixChat shows when we are logged in. The precise view is
139139
* determined by the page_type property.
140140
*
141-
* Currently it's very tightly coupled with MatrixChat. We should try to do
141+
* Currently, it's very tightly coupled with MatrixChat. We should try to do
142142
* something about that.
143143
*
144144
* Components mounted below us can access the matrix client via the react context.
@@ -147,7 +147,6 @@ interface IState {
147147
class LoggedInView extends React.Component<IProps, IState> {
148148
static displayName = 'LoggedInView';
149149

150-
private dispatcherRef: string;
151150
protected readonly _matrixClient: MatrixClient;
152151
protected readonly _roomView: React.RefObject<any>;
153152
protected readonly _resizeContainer: React.RefObject<HTMLDivElement>;
@@ -213,7 +212,6 @@ class LoggedInView extends React.Component<IProps, IState> {
213212
componentWillUnmount() {
214213
document.removeEventListener('keydown', this.onNativeKeyDown, false);
215214
CallHandler.instance.removeListener(CallHandlerEvent.CallState, this.onCallState);
216-
dis.unregister(this.dispatcherRef);
217215
this._matrixClient.removeListener("accountData", this.onAccountData);
218216
this._matrixClient.removeListener("sync", this.onSync);
219217
this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents);

src/components/views/elements/ErrorBoundary.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,19 @@ export default class ErrorBoundary extends React.PureComponent<{}, IState> {
106106
</React.Fragment>;
107107
}
108108

109+
let clearCacheButton: JSX.Element;
110+
// we only show this button if there is an initialised MatrixClient otherwise we can't clear the cache
111+
if (MatrixClientPeg.get()) {
112+
clearCacheButton = <AccessibleButton onClick={this.onClearCacheAndReload} kind='danger'>
113+
{ _t("Clear cache and reload") }
114+
</AccessibleButton>;
115+
}
116+
109117
return <div className="mx_ErrorBoundary">
110118
<div className="mx_ErrorBoundary_body">
111119
<h1>{ _t("Something went wrong!") }</h1>
112120
{ bugReportSection }
113-
<AccessibleButton onClick={this.onClearCacheAndReload} kind='danger'>
114-
{ _t("Clear cache and reload") }
115-
</AccessibleButton>
121+
{ clearCacheButton }
116122
</div>
117123
</div>;
118124
}

0 commit comments

Comments
 (0)