From d4a58bdb2a979eb0846e4c29bb08cd3dab2579d9 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Thu, 14 Jan 2021 11:53:20 +0200 Subject: [PATCH] WIP minimize --- res/css/views/dialogs/_HostSignupDialog.scss | 50 +++++++-------- .../structures/HostSignupAction.tsx | 21 +------ src/components/structures/LoggedInView.tsx | 2 + .../views/dialogs/HostSignupDialog.tsx | 63 +++++++++---------- .../views/host_signup/HostSignupContainer.tsx | 36 +++++++++++ src/stores/OwnProfileStore.ts | 11 ++++ 6 files changed, 108 insertions(+), 75 deletions(-) create mode 100644 src/components/views/host_signup/HostSignupContainer.tsx diff --git a/res/css/views/dialogs/_HostSignupDialog.scss b/res/css/views/dialogs/_HostSignupDialog.scss index 1cc6677d26..130fdb44a6 100644 --- a/res/css/views/dialogs/_HostSignupDialog.scss +++ b/res/css/views/dialogs/_HostSignupDialog.scss @@ -15,40 +15,40 @@ limitations under the License. */ .mx_HostSignupDialog { - z-index: unset; -} - -.mx_HostSignupBaseDialog { max-height: 600px; width: 580px; - position: inherit; - .mx_HostSignupDialog_container { - height: 90%; + .mx_HostSignupDialog_info { + text-align: center; - .mx_HostSignupDialog_info { - text-align: center; - - .mx_HostSignupDialog_content { - margin-top: 64px; - margin-bottom: 45px; - } + .mx_HostSignupDialog_content { + margin-top: 64px; + margin-bottom: 45px; } + } - iframe { - width: 100%; - height: 100%; - border: none; - background-color: #fff; - } + iframe { + width: 100%; + height: 100%; + border: none; + background-color: #fff; } } -.mx_HostSignupBaseDialog_minimized { - display: none; -} - -.mx_HostSignupDialog_persisted { +.mx_HostSignup_persisted { width: 580px; height: 600px; + top: 0; + left: 0; + position: fixed; +} + +.mx_HostSignupDialog_minimized { + position: fixed; + bottom: 100px; + right: 100px; + width: 200px; + height: 120px; + overflow: hidden; + z-index: 6000; } diff --git a/src/components/structures/HostSignupAction.tsx b/src/components/structures/HostSignupAction.tsx index d97dbcd7c1..266114bb2a 100644 --- a/src/components/structures/HostSignupAction.tsx +++ b/src/components/structures/HostSignupAction.tsx @@ -15,35 +15,20 @@ limitations under the License. */ import * as React from "react"; -import HostSignupDialog from "../views/dialogs/HostSignupDialog"; -import Modal, {IHandle} from "../../Modal"; import { IconizedContextMenuOption, IconizedContextMenuOptionList, } from "../views/context_menus/IconizedContextMenu"; import { _t } from "../../languageHandler"; +import { OwnProfileStore } from "../../stores/OwnProfileStore"; interface IProps {} interface IState {} export default class HostSignupAction extends React.PureComponent { - private closingAllowed = false; - private modalRef: IHandle; - - private openDialog = () => { - this.modalRef = Modal.createTrackedDialog( - 'Host Signup Open', '', HostSignupDialog, { - requestClose: this.requestClose, - }, "mx_HostSignupDialog", false, true, { - onBeforeClose: async () => this.closingAllowed, - }, - ); - } - - private requestClose = () => { - this.closingAllowed = true; - this.modalRef.close(); + private openDialog = async () => { + await OwnProfileStore.instance.setHostSignupActive(true); } public render(): React.ReactNode { diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index ec5afd13f0..fd9a712536 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -54,6 +54,7 @@ import { ToggleRightPanelPayload } from "../../dispatcher/payloads/ToggleRightPa import { IThreepidInvite } from "../../stores/ThreepidInviteStore"; import Modal from "../../Modal"; import { ICollapseConfig } from "../../resizer/distributors/collapse"; +import HostSignupContainer from '../views/host_signup/HostSignupContainer'; // We need to fetch each pinned message individually (if we don't already have it) // so each pinned message may trigger a request. Limit the number per room for sanity. @@ -632,6 +633,7 @@ class LoggedInView extends React.Component { + ); } diff --git a/src/components/views/dialogs/HostSignupDialog.tsx b/src/components/views/dialogs/HostSignupDialog.tsx index 90b33e48bc..b9dbcfcbcf 100644 --- a/src/components/views/dialogs/HostSignupDialog.tsx +++ b/src/components/views/dialogs/HostSignupDialog.tsx @@ -15,21 +15,16 @@ limitations under the License. */ import * as React from "react"; -import BaseDialog from '../../views/dialogs/BaseDialog'; -import GenericToast from "../toasts/GenericToast"; import Modal from "../../../Modal"; import PersistedElement from "../elements/PersistedElement"; import QuestionDialog from './QuestionDialog'; import SdkConfig from "../../../SdkConfig"; -import ToastStore from "../../../stores/ToastStore"; import {_t} from "../../../languageHandler"; import {MatrixClientPeg} from "../../../MatrixClientPeg"; import {OwnProfileStore} from "../../../stores/OwnProfileStore"; import {IPostmessage, IPostmessageResponseData, PostmessageAction} from "./HostSignupDialogTypes"; -interface IProps { - requestClose(): void; -} +interface IProps {} interface IState { completed: boolean; @@ -63,6 +58,9 @@ export default class HostSignupDialog extends React.PureComponent { - ToastStore.sharedInstance().addOrReplaceToast({ - priority: 0, - key: 'host_signup_dialog', - title: "Building your home", - icon: "verification", - props: { - description: "", - onAccept: this.maximizeDialog, - acceptLabel: "Return", - }, - component: GenericToast, - }); this.setState({ minimized: true, }); - this.props.requestClose(); + } + + 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 OwnProfileStore.instance.setHostSignupActive(false); } private onFinished = (result: boolean) => { if (result || this.state.completed) { // We're done, close - this.props.requestClose(); + return this.closeDialog(); } else { Modal.createDialog( QuestionDialog, @@ -119,7 +112,7 @@ export default class HostSignupDialog extends React.PureComponent { if (result) { - this.props.requestClose(); + return this.closeDialog(); } }, }, @@ -160,20 +153,20 @@ export default class HostSignupDialog extends React.PureComponent +
- -
+
+
{this.state.loadIframe &&