Page MenuHomePhabricator

D3763.id11730.diff
No OneTemporary

D3763.id11730.diff

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
@@ -2,7 +2,6 @@
import classNames from 'classnames';
import invariant from 'invariant';
-import _pickBy from 'lodash/fp/pickBy';
import * as React from 'react';
import {
@@ -95,6 +94,7 @@
+queuedChanges: ThreadChanges,
+setQueuedChanges: SetState<ThreadChanges>,
+namePlaceholder: string,
+ +changeQueued: boolean,
};
class ThreadSettingsModal extends React.PureComponent<Props> {
nameInput: ?HTMLInputElement;
@@ -154,18 +154,6 @@
: this.props.threadInfo[key];
}
- changeQueued() {
- return (
- Object.keys(
- _pickBy(
- value => value !== null && value !== undefined,
- // the lodash/fp libdef coerces the returned object's properties to the
- // same type, which means it only works for object-as-maps $FlowFixMe
- )(this.props.queuedChanges),
- ).length > 0
- );
- }
-
render() {
const { threadInfo } = this.props;
const inputDisabled =
@@ -223,7 +211,7 @@
<Button
type="submit"
onClick={this.onSubmit}
- disabled={inputDisabled || !this.changeQueued()}
+ disabled={inputDisabled || !this.props.changeQueued}
className={css.save_button}
>
Save
@@ -454,6 +442,13 @@
return robotextName(threadInfo, viewerID, userInfos);
}, [threadInfo, userInfos, viewerID]);
+ const changeQueued: boolean = React.useMemo(
+ () =>
+ Object.values(queuedChanges).filter(v => v !== null && v !== undefined)
+ .length > 0,
+ [queuedChanges],
+ );
+
if (!threadInfo) {
return (
<Modal onClose={modalContext.clearModal} name="Invalid thread">
@@ -484,6 +479,7 @@
queuedChanges={queuedChanges}
setQueuedChanges={setQueuedChanges}
namePlaceholder={namePlaceholder}
+ changeQueued={changeQueued}
/>
);
},

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 7:36 PM (20 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2445217
Default Alt Text
D3763.id11730.diff (2 KB)

Event Timeline