From a4714829f7fddabf5367c88830f48ff2b866c201 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 1 Dec 2021 10:54:14 +0000 Subject: [PATCH] Hide clear cache and reload button if crash is before client init (#7242) --- src/components/structures/LoggedInView.tsx | 4 +--- src/components/views/elements/ErrorBoundary.tsx | 12 +++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index 777e83d5e6..427e5f8467 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -138,7 +138,7 @@ interface IState { * This is what our MatrixChat shows when we are logged in. The precise view is * 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. * * Components mounted below us can access the matrix client via the react context. @@ -147,7 +147,6 @@ interface IState { class LoggedInView extends React.Component { static displayName = 'LoggedInView'; - private dispatcherRef: string; protected readonly _matrixClient: MatrixClient; protected readonly _roomView: React.RefObject; protected readonly _resizeContainer: React.RefObject; @@ -213,7 +212,6 @@ class LoggedInView extends React.Component { componentWillUnmount() { document.removeEventListener('keydown', this.onNativeKeyDown, false); CallHandler.instance.removeListener(CallHandlerEvent.CallState, this.onCallState); - dis.unregister(this.dispatcherRef); this._matrixClient.removeListener("accountData", this.onAccountData); this._matrixClient.removeListener("sync", this.onSync); this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents); diff --git a/src/components/views/elements/ErrorBoundary.tsx b/src/components/views/elements/ErrorBoundary.tsx index 7e8686a35c..78f96ddd73 100644 --- a/src/components/views/elements/ErrorBoundary.tsx +++ b/src/components/views/elements/ErrorBoundary.tsx @@ -106,13 +106,19 @@ export default class ErrorBoundary extends React.PureComponent<{}, IState> { ; } + 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 = + { _t("Clear cache and reload") } + ; + } + return

{ _t("Something went wrong!") }

{ bugReportSection } - - { _t("Clear cache and reload") } - + { clearCacheButton }
; }