Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3348211
D3783.id11760.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D3783.id11760.diff
View Options
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
@@ -101,6 +101,7 @@
+onChangeThreadType: (event: SyntheticEvent<HTMLInputElement>) => void,
+onChangeAccountPassword: (event: SyntheticEvent<HTMLInputElement>) => void,
+hasPermissionForTab: (thread: ThreadInfo, tab: TabType) => boolean,
+ +deleteThreadAction: () => Promise<LeaveThreadPayload>,
};
class ThreadSettingsModal extends React.PureComponent<Props> {
nameInput: ?HTMLInputElement;
@@ -316,30 +317,9 @@
event.preventDefault();
this.props.dispatchActionPromise(
deleteThreadActionTypes,
- this.deleteThreadAction(),
+ this.props.deleteThreadAction(),
);
};
-
- async deleteThreadAction() {
- try {
- const response = await this.props.deleteThread(
- this.props.threadInfo.id,
- this.props.accountPassword,
- );
- this.props.onClose();
- return response;
- } catch (e) {
- const errorMessage =
- e.message === 'invalid_credentials'
- ? 'wrong password'
- : 'unknown error';
- this.props.setErrorMessage(errorMessage);
- this.props.setAccountPassword('');
- invariant(this.accountPasswordInput, 'accountPasswordInput ref unset');
- this.accountPasswordInput.focus();
- throw e;
- }
- }
}
const deleteThreadLoadingStatusSelector = createLoadingStatusSelector(
@@ -473,6 +453,25 @@
[],
);
+ const deleteThreadAction = React.useCallback(async () => {
+ invariant(threadInfo, 'threadInfo should exist in deleteThreadAction');
+ try {
+ const response = await callDeleteThread(threadInfo.id, accountPassword);
+ modalContext.clearModal();
+ return response;
+ } catch (e) {
+ setErrorMessage(
+ e.message === 'invalid_credentials'
+ ? 'wrong password'
+ : 'unknown error',
+ );
+ setAccountPassword('');
+ // TODO: accountPasswordInput.focus()
+ // (once ref is moved up to functional component)
+ throw e;
+ }
+ }, [accountPassword, callDeleteThread, modalContext, threadInfo]);
+
if (!threadInfo) {
return (
<Modal onClose={modalContext.clearModal} name="Invalid thread">
@@ -510,6 +509,7 @@
onChangeThreadType={onChangeThreadType}
onChangeAccountPassword={onChangeAccountPassword}
hasPermissionForTab={hasPermissionForTab}
+ deleteThreadAction={deleteThreadAction}
/>
);
},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 2:01 PM (2 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571068
Default Alt Text
D3783.id11760.diff (2 KB)
Attached To
Mode
D3783: [web] Move `deleteThreadAction` up from `ThreadSettingsModal` to `ConnectedThreadSettingsModal`
Attached
Detach File
Event Timeline
Log In to Comment