From 61f10108875201dd4629283c062ba520889899ad Mon Sep 17 00:00:00 2001 From: Julien Wajsberg Date: Mon, 6 Jan 2025 19:54:36 +0100 Subject: [PATCH] Remove a warning when deleting a remote profile --- src/components/app/MenuButtons/index.js | 54 +++++++++++-------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/components/app/MenuButtons/index.js b/src/components/app/MenuButtons/index.js index c5987f06fb..062bbc7cb6 100644 --- a/src/components/app/MenuButtons/index.js +++ b/src/components/app/MenuButtons/index.js @@ -89,7 +89,7 @@ type DispatchProps = {| type Props = ConnectedProps; type State = $ReadOnly<{| - metaInfoPanelState: 'initial' | 'delete-confirmation' | 'profile-deleted', + metaInfoPanelState: 'initial' | 'delete-confirmation', |}>; class MenuButtonsImpl extends React.PureComponent { @@ -129,9 +129,6 @@ class MenuButtonsImpl extends React.PureComponent { _onProfileDeleted = () => { this.props.profileRemotelyDeleted(); - this.setState({ - metaInfoPanelState: 'profile-deleted', - }); }; _resetMetaInfoState = () => { @@ -196,42 +193,37 @@ class MenuButtonsImpl extends React.PureComponent { ); } - case 'delete-confirmation': { - if (!currentProfileUploadedInformation) { - throw new Error( - `We're in the state "delete-confirmation" but there's no stored data for this profile, this should not happen.` - ); - } - - const { name, profileToken, jwtToken } = - currentProfileUploadedInformation; - - if (!jwtToken) { - throw new Error( - `We're in the state "delete-confirmation" but there's no JWT token for this profile, this should not happen.` + case 'delete-confirmation': + if (currentProfileUploadedInformation) { + const { name, profileToken, jwtToken } = + currentProfileUploadedInformation; + + if (!jwtToken) { + throw new Error( + `We're in the state "delete-confirmation" but there's no JWT token for this profile, this should not happen.` + ); + } + + const slicedProfileToken = profileToken.slice(0, 6); + const profileName = name ? name : `Profile #${slicedProfileToken}`; + return ( + ); } - const slicedProfileToken = profileToken.slice(0, 6); - const profileName = name ? name : `Profile #${slicedProfileToken}`; - return ( - - ); - } + // The profile data has been deleted - case 'profile-deleted': // Note that can also render // in some situations. However it's not suitable for this case, because // we still have to pass jwtToken / profileToken, and we don't have // these values anymore when we're in this state. return ; - default: throw assertExhaustiveCheck(metaInfoPanelState); }