Skip to content

Commit

Permalink
compose [nfc]: Factor new topicSelectionAllowed out of topicInputVisible
Browse files Browse the repository at this point in the history
We'll use topicSelectionAllowed soon, for zulip#5718.
  • Loading branch information
chrisbobbe committed Apr 27, 2023
1 parent 1919de1 commit 0a90278
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/compose/ComposeBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,17 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
setFocusState(state => ({ ...state, either: state.message || state.topic }));
}, []);

const topicInputVisible = useMemo(() => {
const topicSelectionAllowed = useMemo(() => {
if (isEditing) {
return isStreamOrTopicNarrow(narrow);
}
if (!isStreamNarrow(narrow)) {
return false;
}
return focusState.either;
}, [isEditing, narrow, focusState.either]);
return true;
}, [isEditing, narrow]);

const topicInputVisible = topicSelectionAllowed && (focusState.either || isEditing);

/**
* Inserts text at the message input's cursor position.
Expand Down

0 comments on commit 0a90278

Please sign in to comment.