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 Sep 13, 2023
1 parent 1f894d4 commit a3db1f8
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 @@ -263,15 +263,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 a3db1f8

Please sign in to comment.