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 @@ -98,6 +98,7 @@ +setTab: (tabType: TabType) => void, +onChangeName: (event: SyntheticEvent) => void, +onChangeDescription: (event: SyntheticEvent) => void, + +onChangeColor: (color: string) => void, }; class ThreadSettingsModal extends React.PureComponent { nameInput: ?HTMLInputElement; @@ -176,7 +177,7 @@ threadDescriptionOnChange={this.props.onChangeDescription} threadDescriptionDisabled={inputDisabled} threadColorCurrentColor={this.possiblyChangedValue('color')} - threadColorOnColorSelection={this.onChangeColor} + threadColorOnColorSelection={this.props.onChangeColor} /> ); } else if (this.props.currentTabType === 'privacy') { @@ -292,14 +293,6 @@ this.accountPasswordInput = accountPasswordInput; }; - onChangeColor = (color: string) => { - const newValue = color !== this.props.threadInfo.color ? color : undefined; - this.props.setQueuedChanges({ - ...this.props.queuedChanges, - color: newValue, - }); - }; - onChangeThreadType = (event: SyntheticEvent) => { const uiValue = assertThreadType(parseInt(event.currentTarget.value, 10)); const newValue = @@ -449,6 +442,17 @@ [queuedChanges, threadInfo], ); + const onChangeColor = React.useCallback( + (color: string) => { + invariant(threadInfo, 'threadInfo should exist in onChangeColor'); + setQueuedChanges({ + ...queuedChanges, + color: color !== threadInfo.color ? color : undefined, + }); + }, + [queuedChanges, threadInfo], + ); + if (!threadInfo) { return ( @@ -483,6 +487,7 @@ setTab={setTab} onChangeName={onChangeName} onChangeDescription={onChangeDescription} + onChangeColor={onChangeColor} /> ); },