Ensure iframe gets maximize/minimize events

This commit is contained in:
Jason Robinson 2021-02-04 18:30:12 +02:00
parent 6ccce7142c
commit 987ee702d3
2 changed files with 18 additions and 8 deletions

View file

@ -64,10 +64,14 @@ export default class HostSignupDialog extends React.PureComponent<IProps, IState
this.onAccountDetailsRequest();
break;
case PostmessageAction.Maximize:
this.maximizeDialog();
this.setState({
minimized: false,
});
break;
case PostmessageAction.Minimize:
this.minimizeDialog();
this.setState({
minimized: true,
});
break;
case PostmessageAction.SetupComplete:
// Set as completed but let the user close the modal themselves
@ -82,17 +86,23 @@ export default class HostSignupDialog extends React.PureComponent<IProps, IState
}
private maximizeDialog = () => {
if (this.state.minimized) {
this.setState({
minimized: false,
});
}
this.setState({
minimized: false,
});
// Send this action to the iframe so it can act accordingly
this.sendMessage({
action: PostmessageAction.Maximize,
});
}
private minimizeDialog = () => {
this.setState({
minimized: true,
});
// Send this action to the iframe so it can act accordingly
this.sendMessage({
action: PostmessageAction.Minimize,
});
}
private closeDialog = async () => {

View file

@ -38,7 +38,7 @@ export interface IPostmessageRequestData {
export interface IPostmessageResponseData {
action: PostmessageAction;
account: IAccountData;
account?: IAccountData;
}
export interface IPostmessage {