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 @@ -88,10 +88,11 @@ +onClose: () => void, +errorMessage: string, +setErrorMessage: SetState, + +accountPassword: string, + +setAccountPassword: SetState, }; type State = { +queuedChanges: ThreadChanges, - +accountPassword: string, +currentTabType: TabType, }; class ThreadSettingsModal extends React.PureComponent { @@ -102,7 +103,6 @@ super(props); this.state = { queuedChanges: Object.freeze({}), - accountPassword: '', currentTabType: 'general', }; } @@ -210,7 +210,7 @@ } else if (this.state.currentTabType === 'delete') { mainContent = ( ) => { const target = event.currentTarget; - this.setState({ accountPassword: target.value }); + this.props.setAccountPassword(target.value); }; onSubmit = (event: SyntheticEvent) => { @@ -391,11 +391,11 @@ return response; } catch (e) { this.props.setErrorMessage('unknown error'); + this.props.setAccountPassword(''); this.setState( prevState => ({ ...prevState, queuedChanges: Object.freeze({}), - accountPassword: '', currentTabType: 'general', }), () => { @@ -419,7 +419,7 @@ try { const response = await this.props.deleteThread( this.props.threadInfo.id, - this.state.accountPassword, + this.props.accountPassword, ); this.props.onClose(); return response; @@ -429,18 +429,9 @@ ? 'wrong password' : 'unknown error'; this.props.setErrorMessage(errorMessage); - this.setState( - { - accountPassword: '', - }, - () => { - invariant( - this.accountPasswordInput, - 'accountPasswordInput ref unset', - ); - this.accountPasswordInput.focus(); - }, - ); + this.props.setAccountPassword(''); + invariant(this.accountPasswordInput, 'accountPasswordInput ref unset'); + this.accountPasswordInput.focus(); throw e; } } @@ -472,6 +463,7 @@ ); const modalContext = useModalContext(); const [errorMessage, setErrorMessage] = React.useState(''); + const [accountPassword, setAccountPassword] = React.useState(''); if (!threadInfo) { return ( @@ -496,6 +488,8 @@ onClose={modalContext.clearModal} errorMessage={errorMessage} setErrorMessage={setErrorMessage} + accountPassword={accountPassword} + setAccountPassword={setAccountPassword} /> ); },