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 @@ -14,6 +14,7 @@ import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors'; import { threadInfoSelector } from 'lib/selectors/thread-selectors'; import { threadHasPermission, robotextName } from 'lib/shared/thread-utils'; +import { type SetState } from 'lib/types/hook-types.js'; import { type ThreadInfo, threadTypes, @@ -85,10 +86,11 @@ update: UpdateThreadRequest, ) => Promise, +onClose: () => void, + +errorMessage: string, + +setErrorMessage: SetState, }; type State = { +queuedChanges: ThreadChanges, - +errorMessage: string, +accountPassword: string, +currentTabType: TabType, }; @@ -100,7 +102,7 @@ super(props); this.state = { queuedChanges: Object.freeze({}), - errorMessage: '', + accountPassword: '', currentTabType: 'general', }; @@ -294,7 +296,7 @@
{buttons}
- {this.state.errorMessage} + {this.props.errorMessage}
@@ -389,12 +391,12 @@ this.props.onClose(); return response; } catch (e) { + this.props.setErrorMessage('unknown error'); this.setState( prevState => ({ ...prevState, queuedChanges: Object.freeze({}), accountPassword: '', - errorMessage: 'unknown error', currentTabType: 'general', }), () => { @@ -427,10 +429,10 @@ e.message === 'invalid_credentials' ? 'wrong password' : 'unknown error'; + this.props.setErrorMessage(errorMessage); this.setState( { accountPassword: '', - errorMessage: errorMessage, }, () => { invariant( @@ -470,6 +472,7 @@ state => threadInfoSelector(state)[props.threadID], ); const modalContext = useModalContext(); + const [errorMessage, setErrorMessage] = React.useState(''); if (!threadInfo) { return ( @@ -492,6 +495,8 @@ changeThreadSettings={callChangeThreadSettings} dispatchActionPromise={dispatchActionPromise} onClose={modalContext.clearModal} + errorMessage={errorMessage} + setErrorMessage={setErrorMessage} /> ); },