diff --git a/web/modals/threads/thread-settings-modal.react.js b/web/modals/threads/thread-settings-modal.react.js --- a/web/modals/threads/thread-settings-modal.react.js +++ b/web/modals/threads/thread-settings-modal.react.js @@ -90,10 +90,11 @@ +setErrorMessage: SetState, +accountPassword: string, +setAccountPassword: SetState, + +currentTabType: TabType, + +setCurrentTabType: SetState, }; type State = { +queuedChanges: ThreadChanges, - +currentTabType: TabType, }; class ThreadSettingsModal extends React.PureComponent { nameInput: ?HTMLInputElement; @@ -103,7 +104,6 @@ super(props); this.state = { queuedChanges: Object.freeze({}), - currentTabType: 'general', }; } @@ -113,7 +113,7 @@ } componentDidUpdate(prevProps: Props) { - if (this.state.currentTabType !== 'delete') { + if (this.props.currentTabType !== 'delete') { return; } @@ -181,10 +181,10 @@ const { threadInfo } = this.props; const inputDisabled = this.props.changeInProgress || - !this.hasPermissionForTab(threadInfo, this.state.currentTabType); + !this.hasPermissionForTab(threadInfo, this.props.currentTabType); let mainContent = null; - if (this.state.currentTabType === 'general') { + if (this.props.currentTabType === 'general') { mainContent = ( ); - } else if (this.state.currentTabType === 'privacy') { + } else if (this.props.currentTabType === 'privacy') { mainContent = ( ); - } else if (this.state.currentTabType === 'delete') { + } else if (this.props.currentTabType === 'delete') { mainContent = ( , ]; @@ -268,7 +268,7 @@ name="Privacy" tabType="privacy" onClick={this.setTab} - selected={this.state.currentTabType === 'privacy'} + selected={this.props.currentTabType === 'privacy'} key="privacy" />, ); @@ -280,7 +280,7 @@ name="Delete" tabType="delete" onClick={this.setTab} - selected={this.state.currentTabType === 'delete'} + selected={this.props.currentTabType === 'delete'} key="delete" />, ); @@ -305,7 +305,7 @@ } setTab = (tabType: TabType) => { - this.setState({ currentTabType: tabType }); + this.props.setCurrentTabType(tabType); }; nameInputRef = (nameInput: ?HTMLInputElement) => { @@ -392,11 +392,11 @@ } catch (e) { this.props.setErrorMessage('unknown error'); this.props.setAccountPassword(''); + this.props.setCurrentTabType('general'); this.setState( prevState => ({ ...prevState, queuedChanges: Object.freeze({}), - currentTabType: 'general', }), () => { invariant(this.nameInput, 'nameInput ref unset'); @@ -464,6 +464,9 @@ const modalContext = useModalContext(); const [errorMessage, setErrorMessage] = React.useState(''); const [accountPassword, setAccountPassword] = React.useState(''); + const [currentTabType, setCurrentTabType] = React.useState( + 'general', + ); if (!threadInfo) { return ( @@ -490,6 +493,8 @@ setErrorMessage={setErrorMessage} accountPassword={accountPassword} setAccountPassword={setAccountPassword} + currentTabType={currentTabType} + setCurrentTabType={setCurrentTabType} /> ); },