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

Don't unnecessarily persist the host signup dialog #9043

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
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
11 changes: 0 additions & 11 deletions res/css/views/dialogs/_HostSignupDialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,6 @@ limitations under the License.
right: 25px;
}

.mx_HostSignup_persisted {
width: 90vw;
max-width: 580px;
height: 80vh;
max-height: 600px;
top: 0;
left: 0;
position: fixed;
display: none;
}

.mx_HostSignupDialog_minimized {
position: fixed;
bottom: 80px;
Expand Down
121 changes: 56 additions & 65 deletions src/components/views/dialogs/HostSignupDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { logger } from "matrix-js-sdk/src/logger";

import AccessibleButton from "../elements/AccessibleButton";
import Modal from "../../../Modal";
import PersistedElement from "../elements/PersistedElement";
import QuestionDialog from './QuestionDialog';
import SdkConfig from "../../../SdkConfig";
import { _t } from "../../../languageHandler";
Expand All @@ -35,8 +34,6 @@ import {
import { IConfigOptions } from "../../../IConfigOptions";
import { SnakedObject } from "../../../utils/SnakedObject";

const HOST_SIGNUP_KEY = "host_signup";

interface IProps {}

interface IState {
Expand Down Expand Up @@ -111,8 +108,6 @@ export default class HostSignupDialog extends React.PureComponent<IProps, IState

private closeDialog = async () => {
window.removeEventListener("message", this.messageHandler);
// Ensure we destroy the host signup persisted element
PersistedElement.destroyElement("host_signup");
// Finally clear the flag in
return HostSignupStore.instance.setHostSignupActive(false);
};
Expand Down Expand Up @@ -235,69 +230,65 @@ export default class HostSignupDialog extends React.PureComponent<IProps, IState

public render(): React.ReactNode {
return (
<div className="mx_HostSignup_persisted">
<PersistedElement key={HOST_SIGNUP_KEY} persistKey={HOST_SIGNUP_KEY}>
<div className={classNames({ "mx_Dialog_wrapper": !this.state.minimized })}>
<div
className={classNames("mx_Dialog",
<div className={classNames({ "mx_Dialog_wrapper": !this.state.minimized })}>
<div
className={classNames("mx_Dialog",
{
"mx_HostSignupDialog_minimized": this.state.minimized,
"mx_HostSignupDialog": !this.state.minimized,
},
)}
>
{ this.state.minimized &&
<div className="mx_Dialog_header mx_Dialog_headerWithButton">
<div className="mx_Dialog_title">
{ _t("%(hostSignupBrand)s Setup", {
hostSignupBrand: this.config.get("brand"),
}) }
</div>
<AccessibleButton
className="mx_HostSignup_maximize_button"
onClick={this.maximizeDialog}
aria-label={_t("Maximise dialog")}
title={_t("Maximise dialog")}
/>
</div>
}
{ !this.state.minimized &&
<div className="mx_Dialog_header mx_Dialog_headerWithCancel">
<AccessibleButton
onClick={this.minimizeDialog}
className="mx_HostSignup_minimize_button"
aria-label={_t("Minimise dialog")}
title={_t("Minimise dialog")}
/>
<AccessibleButton
onClick={this.onCloseClick}
className="mx_Dialog_cancelButton"
aria-label={_t("Close dialog")}
title={_t("Close dialog")}
/>
</div>
}
{ this.state.error &&
<div>
{ this.state.error }
</div>
}
{ !this.state.error &&
<iframe
title={_t(
"Upgrade to %(hostSignupBrand)s",
{
"mx_HostSignupDialog_minimized": this.state.minimized,
"mx_HostSignupDialog": !this.state.minimized,
hostSignupBrand: this.config.get("brand"),
},
)}
>
{ this.state.minimized &&
<div className="mx_Dialog_header mx_Dialog_headerWithButton">
<div className="mx_Dialog_title">
{ _t("%(hostSignupBrand)s Setup", {
hostSignupBrand: this.config.get("brand"),
}) }
</div>
<AccessibleButton
className="mx_HostSignup_maximize_button"
onClick={this.maximizeDialog}
aria-label={_t("Maximise dialog")}
title={_t("Maximise dialog")}
/>
</div>
}
{ !this.state.minimized &&
<div className="mx_Dialog_header mx_Dialog_headerWithCancel">
<AccessibleButton
onClick={this.minimizeDialog}
className="mx_HostSignup_minimize_button"
aria-label={_t("Minimise dialog")}
title={_t("Minimise dialog")}
/>
<AccessibleButton
onClick={this.onCloseClick}
className="mx_Dialog_cancelButton"
aria-label={_t("Close dialog")}
title={_t("Close dialog")}
/>
</div>
}
{ this.state.error &&
<div>
{ this.state.error }
</div>
}
{ !this.state.error &&
<iframe
title={_t(
"Upgrade to %(hostSignupBrand)s",
{
hostSignupBrand: this.config.get("brand"),
},
)}
src={this.config.get("url")}
ref={this.iframeRef}
sandbox="allow-forms allow-scripts allow-same-origin allow-popups"
/>
}
</div>
</div>
</PersistedElement>
src={this.config.get("url")}
ref={this.iframeRef}
sandbox="allow-forms allow-scripts allow-same-origin allow-popups"
/>
}
</div>
</div>
);
}
Expand Down