retrieve toast params from function getToastParams

This commit is contained in:
Aakansha Doshi 2022-07-08 12:46:35 +05:30
parent a85b3147ce
commit cfca580d74

View file

@ -468,6 +468,15 @@ class App extends React.Component<AppProps, AppState> {
); );
} }
getToastParams = () => {
const isBrowserZoomed = this.state.toastMessage === t("alerts.browserZoom");
return {
message: this.state.toastMessage!,
duration: isBrowserZoomed ? Infinity : undefined,
closable: isBrowserZoomed,
clearToast: this.clearToast,
};
};
public render() { public render() {
const { zenModeEnabled, viewModeEnabled } = this.state; const { zenModeEnabled, viewModeEnabled } = this.state;
const selectedElement = getSelectedElements( const selectedElement = getSelectedElements(
@ -550,16 +559,7 @@ class App extends React.Component<AppProps, AppState> {
/> />
)} )}
{this.state.toastMessage !== null && ( {this.state.toastMessage !== null && (
<Toast <Toast {...this.getToastParams()} />
message={this.state.toastMessage}
clearToast={this.clearToast}
duration={
this.state.toastMessage === t("alerts.browserZoom")
? Infinity
: undefined
}
closable={this.state.toastMessage === t("alerts.browserZoom")}
/>
)} )}
<main>{this.renderCanvas()}</main> <main>{this.renderCanvas()}</main>
</DeviceContext.Provider> </DeviceContext.Provider>