Skip to content

Commit c4f9341

Browse files
committed
compose [nfc]: Extract isTopicVacuous helper
This will later (in another PR) be useful for checking emptiness when realmEmptyTopicDisplayName is given. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 6d6dc6d commit c4f9341

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/widgets/compose_box.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,17 @@ class ComposeTopicController extends ComposeController<TopicValidationError> {
160160
return trimmed.isEmpty ? kNoTopicTopic : trimmed;
161161
}
162162

163+
/// Whether [textNormalized] would fail a mandatory-topics check
164+
/// (see [mandatory]).
165+
///
166+
/// The term "Vacuous" draws distinction from [String.isEmpty], in the sense
167+
/// that certain strings are not empty but also indicate the absence of a topic.
168+
bool get isTopicVacuous => textNormalized == kNoTopicTopic;
169+
163170
@override
164171
List<TopicValidationError> _computeValidationErrors() {
165172
return [
166-
if (mandatory && textNormalized == kNoTopicTopic)
173+
if (mandatory && isTopicVacuous)
167174
TopicValidationError.mandatoryButEmpty,
168175

169176
if (

0 commit comments

Comments
 (0)