Skip to content

Commit 26073e8

Browse files
committed
compose [nfc]: Simplify content-input state, deduplicating topic text
Ever since 5827512 made the text input's controller start memoizing `textNormalized` as part of its own state, there's nothing to gain by keeping a copy of it on the widget state too.
1 parent 601936d commit 26073e8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/widgets/compose_box.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,18 +544,15 @@ class _StreamContentInput extends StatefulWidget {
544544
}
545545

546546
class _StreamContentInputState extends State<_StreamContentInput> {
547-
late String _topicTextNormalized;
548-
549547
void _topicChanged() {
550548
setState(() {
551-
_topicTextNormalized = widget.controller.topic.textNormalized;
549+
// The relevant state lives on widget.controller.topic itself.
552550
});
553551
}
554552

555553
@override
556554
void initState() {
557555
super.initState();
558-
_topicTextNormalized = widget.controller.topic.textNormalized;
559556
widget.controller.topic.addListener(_topicChanged);
560557
}
561558

@@ -582,9 +579,11 @@ class _StreamContentInputState extends State<_StreamContentInput> {
582579
?? zulipLocalizations.unknownChannelName;
583580
return _ContentInput(
584581
narrow: widget.narrow,
585-
destination: TopicNarrow(widget.narrow.streamId, TopicName(_topicTextNormalized)),
582+
destination: TopicNarrow(widget.narrow.streamId,
583+
TopicName(widget.controller.topic.textNormalized)),
586584
controller: widget.controller,
587-
hintText: zulipLocalizations.composeBoxChannelContentHint(streamName, _topicTextNormalized));
585+
hintText: zulipLocalizations.composeBoxChannelContentHint(streamName,
586+
widget.controller.topic.textNormalized));
588587
}
589588
}
590589

0 commit comments

Comments
 (0)