2017-02-15 18:44:15 +00:00
|
|
|
/*
|
|
|
|
|
Copyright 2017 Vector Creations Ltd
|
2018-04-27 11:25:13 +01:00
|
|
|
Copyright 2018 New Vector Ltd
|
2020-07-10 19:07:11 +01:00
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
2017-02-15 18:44:15 +00:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
2021-10-22 17:23:32 -05:00
|
|
|
|
2017-02-15 18:44:15 +00:00
|
|
|
import SdkConfig from "../../../SdkConfig";
|
|
|
|
|
import Modal from "../../../Modal";
|
2017-11-13 20:19:33 +01:00
|
|
|
import { _t } from "../../../languageHandler";
|
2021-09-05 16:40:46 +02:00
|
|
|
import QuestionDialog from "./QuestionDialog";
|
|
|
|
|
import BugReportDialog from "./BugReportDialog";
|
|
|
|
|
import BaseDialog from "./BaseDialog";
|
|
|
|
|
import DialogButtons from "../elements/DialogButtons";
|
2021-09-10 19:01:05 +02:00
|
|
|
import { IDialogProps } from "./IDialogProps";
|
2021-09-05 16:40:46 +02:00
|
|
|
|
2021-09-10 19:01:05 +02:00
|
|
|
interface IProps extends IDialogProps {
|
2021-10-29 09:34:25 +01:00
|
|
|
error: Error;
|
2021-09-05 16:40:46 +02:00
|
|
|
}
|
2017-02-15 18:44:15 +00:00
|
|
|
|
2021-09-05 16:40:46 +02:00
|
|
|
export default class SessionRestoreErrorDialog extends React.Component<IProps> {
|
|
|
|
|
private sendBugReport = (): void => {
|
2022-06-14 17:51:51 +01:00
|
|
|
Modal.createDialog(BugReportDialog, {
|
2021-10-29 09:34:25 +01:00
|
|
|
error: this.props.error,
|
|
|
|
|
});
|
2020-08-29 12:14:16 +01:00
|
|
|
};
|
2017-02-15 18:44:15 +00:00
|
|
|
|
2021-09-05 16:40:46 +02:00
|
|
|
private onClearStorageClick = (): void => {
|
2022-06-14 17:51:51 +01:00
|
|
|
Modal.createDialog(QuestionDialog, {
|
2018-04-27 12:38:49 +01:00
|
|
|
title: _t("Sign out"),
|
2019-03-28 16:22:17 +00:00
|
|
|
description: <div>{_t("Sign out and remove encryption keys?")}</div>,
|
2018-04-27 12:38:49 +01:00
|
|
|
button: _t("Sign out"),
|
|
|
|
|
danger: true,
|
|
|
|
|
onFinished: this.props.onFinished,
|
|
|
|
|
});
|
2020-08-29 12:14:16 +01:00
|
|
|
};
|
2017-02-15 18:44:15 +00:00
|
|
|
|
2021-09-05 16:40:46 +02:00
|
|
|
private onRefreshClick = (): void => {
|
2018-04-27 12:38:49 +01:00
|
|
|
// Is this likely to help? Probably not, but giving only one button
|
|
|
|
|
// that clears your storage seems awful.
|
2021-09-05 16:40:46 +02:00
|
|
|
window.location.reload();
|
2020-08-29 12:14:16 +01:00
|
|
|
};
|
2018-04-26 17:07:58 +01:00
|
|
|
|
2021-09-05 16:40:46 +02:00
|
|
|
public render(): JSX.Element {
|
2020-07-10 19:07:11 +01:00
|
|
|
const brand = SdkConfig.get().brand;
|
2017-02-15 18:44:15 +00:00
|
|
|
|
2018-04-30 14:22:18 +01:00
|
|
|
const clearStorageButton = (
|
2021-09-05 16:40:46 +02:00
|
|
|
<button onClick={this.onClearStorageClick} className="danger">
|
2018-04-30 14:22:18 +01:00
|
|
|
{_t("Clear Storage and Sign Out")}
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
|
2018-04-27 12:38:49 +01:00
|
|
|
let dialogButtons;
|
2017-02-15 18:44:15 +00:00
|
|
|
if (SdkConfig.get().bug_report_endpoint_url) {
|
2018-04-27 12:38:49 +01:00
|
|
|
dialogButtons = (
|
|
|
|
|
<DialogButtons
|
|
|
|
|
primaryButton={_t("Send Logs")}
|
2021-09-05 16:40:46 +02:00
|
|
|
onPrimaryButtonClick={this.sendBugReport}
|
2018-04-27 12:38:49 +01:00
|
|
|
focus={true}
|
|
|
|
|
hasCancel={false}
|
|
|
|
|
>
|
2018-04-30 14:34:14 +01:00
|
|
|
{clearStorageButton}
|
2018-04-27 15:56:28 +01:00
|
|
|
</DialogButtons>
|
|
|
|
|
);
|
2018-04-27 12:38:49 +01:00
|
|
|
} else {
|
|
|
|
|
dialogButtons = (
|
|
|
|
|
<DialogButtons
|
|
|
|
|
primaryButton={_t("Refresh")}
|
2021-09-05 16:40:46 +02:00
|
|
|
onPrimaryButtonClick={this.onRefreshClick}
|
2018-04-27 12:38:49 +01:00
|
|
|
focus={true}
|
|
|
|
|
hasCancel={false}
|
|
|
|
|
>
|
2018-04-30 14:34:14 +01:00
|
|
|
{clearStorageButton}
|
2018-04-27 15:56:28 +01:00
|
|
|
</DialogButtons>
|
|
|
|
|
);
|
2017-02-15 18:44:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2021-07-23 10:23:45 +01:00
|
|
|
<BaseDialog
|
|
|
|
|
className="mx_ErrorDialog"
|
|
|
|
|
onFinished={this.props.onFinished}
|
2018-04-27 12:38:49 +01:00
|
|
|
title={_t("Unable to restore session")}
|
2017-12-05 13:52:20 +01:00
|
|
|
contentId="mx_Dialog_content"
|
2018-04-27 12:38:49 +01:00
|
|
|
hasCancel={false}
|
2017-12-05 13:52:20 +01:00
|
|
|
>
|
|
|
|
|
<div className="mx_Dialog_content" id="mx_Dialog_content">
|
2018-04-27 12:38:49 +01:00
|
|
|
<p>{_t("We encountered an error trying to restore your previous session.")}</p>
|
2017-02-15 18:44:15 +00:00
|
|
|
|
2018-04-30 14:25:42 +01:00
|
|
|
<p>
|
|
|
|
|
{_t(
|
2020-07-10 19:07:11 +01:00
|
|
|
"If you have previously used a more recent version of %(brand)s, your session " +
|
2018-04-30 14:25:42 +01:00
|
|
|
"may be incompatible with this version. Close this window and return " +
|
2018-04-30 14:34:14 +01:00
|
|
|
"to the more recent version.",
|
2020-07-10 19:07:11 +01:00
|
|
|
{ brand },
|
2021-04-27 17:23:27 +02:00
|
|
|
)}
|
|
|
|
|
</p>
|
2017-02-15 18:44:15 +00:00
|
|
|
|
2018-04-30 14:25:42 +01:00
|
|
|
<p>
|
|
|
|
|
{_t(
|
|
|
|
|
"Clearing your browser's storage may fix the problem, but will sign you " +
|
2018-04-30 14:34:14 +01:00
|
|
|
"out and cause any encrypted chat history to become unreadable.",
|
2018-04-30 14:25:42 +01:00
|
|
|
)}
|
|
|
|
|
</p>
|
2017-02-15 18:44:15 +00:00
|
|
|
</div>
|
2018-04-27 12:38:49 +01:00
|
|
|
{dialogButtons}
|
2017-02-15 18:44:15 +00:00
|
|
|
</BaseDialog>
|
|
|
|
|
);
|
2020-08-29 12:14:16 +01:00
|
|
|
}
|
|
|
|
|
}
|