mirror of https://github.com/vector-im/riot-web
WIP minimize
parent
d4a58bdb2a
commit
d6af5b3bbd
|
@ -20,7 +20,7 @@ import {
|
|||
IconizedContextMenuOptionList,
|
||||
} from "../views/context_menus/IconizedContextMenu";
|
||||
import { _t } from "../../languageHandler";
|
||||
import { OwnProfileStore } from "../../stores/OwnProfileStore";
|
||||
import { HostSignupStore } from "../../stores/HostSignupStore";
|
||||
|
||||
interface IProps {}
|
||||
|
||||
|
@ -28,7 +28,7 @@ interface IState {}
|
|||
|
||||
export default class HostSignupAction extends React.PureComponent<IProps, IState> {
|
||||
private openDialog = async () => {
|
||||
await OwnProfileStore.instance.setHostSignupActive(true);
|
||||
await HostSignupStore.instance.setHostSignupActive(true);
|
||||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
|
|
|
@ -21,6 +21,7 @@ import QuestionDialog from './QuestionDialog';
|
|||
import SdkConfig from "../../../SdkConfig";
|
||||
import {_t} from "../../../languageHandler";
|
||||
import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
||||
import {HostSignupStore} from "../../../stores/HostSignupStore";
|
||||
import {OwnProfileStore} from "../../../stores/OwnProfileStore";
|
||||
import {IPostmessage, IPostmessageResponseData, PostmessageAction} from "./HostSignupDialogTypes";
|
||||
|
||||
|
@ -72,8 +73,7 @@ export default class HostSignupDialog extends React.PureComponent<IProps, IState
|
|||
});
|
||||
break;
|
||||
case PostmessageAction.CloseDialog:
|
||||
this.onFinished(true);
|
||||
break;
|
||||
return this.onFinished(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,10 +94,10 @@ export default class HostSignupDialog extends React.PureComponent<IProps, IState
|
|||
// Ensure we destroy the host signup persisted element
|
||||
PersistedElement.destroyElement("host_signup");
|
||||
// Finally clear the flag in
|
||||
return OwnProfileStore.instance.setHostSignupActive(false);
|
||||
return HostSignupStore.instance.setHostSignupActive(false);
|
||||
}
|
||||
|
||||
private onFinished = (result: boolean) => {
|
||||
private onFinished = async (result: boolean) => {
|
||||
if (result || this.state.completed) {
|
||||
// We're done, close
|
||||
return this.closeDialog();
|
||||
|
@ -153,7 +153,7 @@ export default class HostSignupDialog extends React.PureComponent<IProps, IState
|
|||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
if (OwnProfileStore.instance.isHostSignupActive) {
|
||||
if (HostSignupStore.instance.isHostSignupActive) {
|
||||
// Run the close dialog actions if we're still active, otherwise good to go
|
||||
return this.closeDialog();
|
||||
}
|
||||
|
|
|
@ -16,14 +16,14 @@ limitations under the License.
|
|||
|
||||
import React, {useState} from 'react';
|
||||
import HostSignupDialog from "../dialogs/HostSignupDialog";
|
||||
import { OwnProfileStore } from "../../../stores/OwnProfileStore";
|
||||
import {HostSignupStore} from "../../../stores/HostSignupStore";
|
||||
import {useEventEmitter} from "../../../hooks/useEventEmitter";
|
||||
import {UPDATE_EVENT} from "../../../stores/AsyncStore";
|
||||
|
||||
const HostSignupContainer = () => {
|
||||
const [isActive, setIsActive] = useState(OwnProfileStore.instance.isHostSignupActive);
|
||||
useEventEmitter(OwnProfileStore.instance, UPDATE_EVENT, () => {
|
||||
setIsActive(OwnProfileStore.instance.isHostSignupActive);
|
||||
const [isActive, setIsActive] = useState(HostSignupStore.instance.isHostSignupActive);
|
||||
useEventEmitter(HostSignupStore.instance, UPDATE_EVENT, () => {
|
||||
setIsActive(HostSignupStore.instance.isHostSignupActive);
|
||||
});
|
||||
|
||||
return <div className="mx_HostSignupContainer">
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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 defaultDispatcher from "../dispatcher/dispatcher";
|
||||
import {AsyncStore} from "./AsyncStore";
|
||||
import {ActionPayload} from "../dispatcher/payloads";
|
||||
|
||||
interface IState {
|
||||
hostSignupActive?: boolean;
|
||||
}
|
||||
|
||||
export class HostSignupStore extends AsyncStore<IState> {
|
||||
private static internalInstance = new HostSignupStore();
|
||||
|
||||
private constructor() {
|
||||
super(defaultDispatcher, {hostSignupActive: false});
|
||||
}
|
||||
|
||||
public static get instance(): HostSignupStore {
|
||||
return HostSignupStore.internalInstance;
|
||||
}
|
||||
|
||||
public get isHostSignupActive(): boolean {
|
||||
return this.state.hostSignupActive;
|
||||
}
|
||||
|
||||
public async setHostSignupActive(status: boolean) {
|
||||
return this.updateState({
|
||||
hostSignupActive: status,
|
||||
});
|
||||
}
|
||||
|
||||
protected onDispatch(payload: ActionPayload) {
|
||||
// Nothing to do
|
||||
}
|
||||
}
|
|
@ -26,7 +26,6 @@ import { _t } from "../languageHandler";
|
|||
interface IState {
|
||||
displayName?: string;
|
||||
avatarUrl?: string;
|
||||
hostSignupActive?: boolean;
|
||||
}
|
||||
|
||||
export class OwnProfileStore extends AsyncStoreWithClient<IState> {
|
||||
|
@ -42,16 +41,6 @@ export class OwnProfileStore extends AsyncStoreWithClient<IState> {
|
|||
return OwnProfileStore.internalInstance;
|
||||
}
|
||||
|
||||
public get isHostSignupActive(): boolean {
|
||||
return this.state.hostSignupActive;
|
||||
}
|
||||
|
||||
public async setHostSignupActive(status: boolean) {
|
||||
await this.updateState({
|
||||
hostSignupActive: status,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name for the user, or null if not present.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue