Skip to content

Commit 5b10ba6

Browse files
committed
compose [nfc]: Simplify choose-body logic by switching on controller
1 parent d2c37a6 commit 5b10ba6

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

lib/widgets/compose_box.dart

+7-13
Original file line numberDiff line numberDiff line change
@@ -1351,21 +1351,15 @@ class _ComposeBoxState extends State<ComposeBox> implements ComposeBoxState {
13511351
}
13521352

13531353
final narrow = widget.narrow;
1354-
switch (narrow) {
1355-
case ChannelNarrow():
1356-
_controller as StreamComposeBoxController;
1354+
switch (_controller) {
1355+
case StreamComposeBoxController(): {
1356+
narrow as ChannelNarrow;
13571357
body = _StreamComposeBoxBody(controller: _controller, narrow: narrow);
1358-
case TopicNarrow():
1359-
_controller as FixedDestinationComposeBoxController;
1360-
body = _FixedDestinationComposeBoxBody(controller: _controller, narrow: narrow);
1361-
case DmNarrow():
1362-
_controller as FixedDestinationComposeBoxController;
1358+
}
1359+
case FixedDestinationComposeBoxController(): {
1360+
narrow as SendableNarrow;
13631361
body = _FixedDestinationComposeBoxBody(controller: _controller, narrow: narrow);
1364-
case CombinedFeedNarrow():
1365-
case MentionsNarrow():
1366-
case StarredMessagesNarrow():
1367-
assert(false);
1368-
body = null;
1362+
}
13691363
}
13701364

13711365
// TODO(#720) dismissable message-send error, maybe something like:

0 commit comments

Comments
 (0)