Hide clear cache and reload button if crash is before client init (#7242)

This commit is contained in:
Michael Telatynski 2021-12-01 10:54:14 +00:00 committed by GitHub
parent 5ba2d16ee1
commit a4714829f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -138,7 +138,7 @@ interface IState {
* This is what our MatrixChat shows when we are logged in. The precise view is * This is what our MatrixChat shows when we are logged in. The precise view is
* determined by the page_type property. * determined by the page_type property.
* *
* Currently it's very tightly coupled with MatrixChat. We should try to do * Currently, it's very tightly coupled with MatrixChat. We should try to do
* something about that. * something about that.
* *
* Components mounted below us can access the matrix client via the react context. * Components mounted below us can access the matrix client via the react context.
@ -147,7 +147,6 @@ interface IState {
class LoggedInView extends React.Component<IProps, IState> { class LoggedInView extends React.Component<IProps, IState> {
static displayName = 'LoggedInView'; static displayName = 'LoggedInView';
private dispatcherRef: string;
protected readonly _matrixClient: MatrixClient; protected readonly _matrixClient: MatrixClient;
protected readonly _roomView: React.RefObject<any>; protected readonly _roomView: React.RefObject<any>;
protected readonly _resizeContainer: React.RefObject<HTMLDivElement>; protected readonly _resizeContainer: React.RefObject<HTMLDivElement>;
@ -213,7 +212,6 @@ class LoggedInView extends React.Component<IProps, IState> {
componentWillUnmount() { componentWillUnmount() {
document.removeEventListener('keydown', this.onNativeKeyDown, false); document.removeEventListener('keydown', this.onNativeKeyDown, false);
CallHandler.instance.removeListener(CallHandlerEvent.CallState, this.onCallState); CallHandler.instance.removeListener(CallHandlerEvent.CallState, this.onCallState);
dis.unregister(this.dispatcherRef);
this._matrixClient.removeListener("accountData", this.onAccountData); this._matrixClient.removeListener("accountData", this.onAccountData);
this._matrixClient.removeListener("sync", this.onSync); this._matrixClient.removeListener("sync", this.onSync);
this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents); this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents);

View File

@ -106,13 +106,19 @@ export default class ErrorBoundary extends React.PureComponent<{}, IState> {
</React.Fragment>; </React.Fragment>;
} }
let clearCacheButton: JSX.Element;
// we only show this button if there is an initialised MatrixClient otherwise we can't clear the cache
if (MatrixClientPeg.get()) {
clearCacheButton = <AccessibleButton onClick={this.onClearCacheAndReload} kind='danger'>
{ _t("Clear cache and reload") }
</AccessibleButton>;
}
return <div className="mx_ErrorBoundary"> return <div className="mx_ErrorBoundary">
<div className="mx_ErrorBoundary_body"> <div className="mx_ErrorBoundary_body">
<h1>{ _t("Something went wrong!") }</h1> <h1>{ _t("Something went wrong!") }</h1>
{ bugReportSection } { bugReportSection }
<AccessibleButton onClick={this.onClearCacheAndReload} kind='danger'> { clearCacheButton }
{ _t("Clear cache and reload") }
</AccessibleButton>
</div> </div>
</div>; </div>;
} }