Skip to content

Commit e913559

Browse files
committed
compose [nfc]: Unhoist a self-user lookup
Also add some blank lines to make the structure of this switch a bit easier to see.
1 parent 6b0bd59 commit e913559

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/widgets/compose_box.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,23 +1404,25 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
14041404

14051405
Widget? _errorBanner(BuildContext context) {
14061406
final store = PerAccountStoreWidget.of(context);
1407-
final selfUser = store.users[store.selfUserId]!;
14081407
switch (widget.narrow) {
14091408
case ChannelNarrow(:final streamId):
14101409
case TopicNarrow(:final streamId):
14111410
final channel = store.streams[streamId];
1411+
final selfUser = store.users[store.selfUserId]!;
14121412
if (channel == null || !store.hasPostingPermission(inChannel: channel,
14131413
user: selfUser, byDate: DateTime.now())) {
14141414
return _ErrorBanner(label:
14151415
ZulipLocalizations.of(context).errorBannerCannotPostInChannelLabel);
14161416
}
1417+
14171418
case DmNarrow(:final otherRecipientIds):
14181419
final hasDeactivatedUser = otherRecipientIds.any((id) =>
14191420
!(store.users[id]?.isActive ?? true));
14201421
if (hasDeactivatedUser) {
14211422
return _ErrorBanner(label:
14221423
ZulipLocalizations.of(context).errorBannerDeactivatedDmLabel);
14231424
}
1425+
14241426
case CombinedFeedNarrow():
14251427
case MentionsNarrow():
14261428
case StarredMessagesNarrow():

0 commit comments

Comments
 (0)