Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3174802
D3795.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
D3795.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
@@ -103,6 +103,7 @@
+hasPermissionForTab: (thread: ThreadInfo, tab: TabType) => boolean,
+deleteThreadAction: () => Promise<LeaveThreadPayload>,
+onDelete: (event: SyntheticEvent<HTMLElement>) => void,
+ +changeThreadSettingsAction: () => Promise<ChangeThreadSettingsPayload>,
};
class ThreadSettingsModal extends React.PureComponent<Props> {
nameInput: ?HTMLInputElement;
@@ -291,28 +292,9 @@
event.preventDefault();
this.props.dispatchActionPromise(
changeThreadSettingsActionTypes,
- this.changeThreadSettingsAction(),
+ this.props.changeThreadSettingsAction(),
);
};
-
- async changeThreadSettingsAction() {
- try {
- const response = await this.props.changeThreadSettings({
- threadID: this.props.threadInfo.id,
- changes: this.props.queuedChanges,
- });
- this.props.onClose();
- return response;
- } catch (e) {
- this.props.setErrorMessage('unknown error');
- this.props.setAccountPassword('');
- this.props.setCurrentTabType('general');
- this.props.setQueuedChanges(Object.freeze({}));
- invariant(this.nameInput, 'nameInput ref unset');
- this.nameInput.focus();
- throw e;
- }
- }
}
const deleteThreadLoadingStatusSelector = createLoadingStatusSelector(
@@ -473,6 +455,29 @@
[deleteThreadAction, dispatchActionPromise],
);
+ const changeThreadSettingsAction = React.useCallback(async () => {
+ invariant(
+ threadInfo,
+ 'threadInfo should exist in changeThreadSettingsAction',
+ );
+ try {
+ const response = await callChangeThreadSettings({
+ threadID: threadInfo.id,
+ changes: queuedChanges,
+ });
+ modalContext.clearModal();
+ return response;
+ } catch (e) {
+ setErrorMessage('unknown_error');
+ setAccountPassword('');
+ setCurrentTabType('general');
+ setQueuedChanges(Object.freeze({}));
+ // TODO: nameInput.focus()
+ // (once ref is moved up to functional component)
+ throw e;
+ }
+ }, [callChangeThreadSettings, modalContext, queuedChanges, threadInfo]);
+
if (!threadInfo) {
return (
<Modal onClose={modalContext.clearModal} name="Invalid thread">
@@ -512,6 +517,7 @@
hasPermissionForTab={hasPermissionForTab}
deleteThreadAction={deleteThreadAction}
onDelete={onDelete}
+ changeThreadSettingsAction={changeThreadSettingsAction}
/>
);
},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 6:04 PM (20 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2444902
Default Alt Text
D3795.diff (2 KB)
Attached To
Mode
D3795: [web] Move `changeThreadSettingsAction` up from `ThreadSettingsModal` to `ConnectedThreadSettingsModal`
Attached
Detach File
Event Timeline
Log In to Comment