@@ -1071,26 +1071,8 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
10711071 super .dispose ();
10721072 }
10731073
1074- Widget ? _errorBanner (BuildContext context) {
1075- if (widget.narrow case DmNarrow (: final otherRecipientIds)) {
1076- final store = PerAccountStoreWidget .of (context);
1077- final hasDeactivatedUser = otherRecipientIds.any ((id) =>
1078- ! (store.users[id]? .isActive ?? true ));
1079- if (hasDeactivatedUser) {
1080- return _ErrorBanner (label: ZulipLocalizations .of (context)
1081- .errorBannerDeactivatedDmLabel);
1082- }
1083- }
1084- return null ;
1085- }
1086-
10871074 @override
10881075 Widget build (BuildContext context) {
1089- final errorBanner = _errorBanner (context);
1090- if (errorBanner != null ) {
1091- return _ComposeBoxContainer (child: errorBanner);
1092- }
1093-
10941076 return _ComposeBoxLayout (
10951077 contentController: _contentController,
10961078 contentFocusNode: _contentFocusNode,
@@ -1127,8 +1109,36 @@ class ComposeBox extends StatelessWidget {
11271109 }
11281110 }
11291111
1112+ Widget ? _errorBanner (BuildContext context) {
1113+ final store = PerAccountStoreWidget .of (context);
1114+ final selfUser = store.users[store.selfUserId]! ;
1115+ switch (narrow) {
1116+ case ChannelNarrow narrow:
1117+ final channel = store.streams[narrow.streamId]! ;
1118+ return channel.hasPostingPermission (selfUser, byDate: DateTime .now (), realmWaitingPeriodThreshold: store.realmWaitingPeriodThreshold)
1119+ ? null : _ErrorBanner (label: ZulipLocalizations .of (context).errorBannerCannotPostInChannelLabel);
1120+ case TopicNarrow narrow:
1121+ final channel = store.streams[narrow.streamId]! ;
1122+ return channel.hasPostingPermission (selfUser, byDate: DateTime .now (), realmWaitingPeriodThreshold: store.realmWaitingPeriodThreshold)
1123+ ? null : _ErrorBanner (label: ZulipLocalizations .of (context).errorBannerCannotPostInChannelLabel);
1124+ case DmNarrow (: final otherRecipientIds):
1125+ final hasDeactivatedUser = otherRecipientIds.any ((id) =>
1126+ ! (store.users[id]? .isActive ?? true ));
1127+ return hasDeactivatedUser ? _ErrorBanner (label: ZulipLocalizations .of (context)
1128+ .errorBannerDeactivatedDmLabel) : null ;
1129+ case CombinedFeedNarrow ():
1130+ case MentionsNarrow ():
1131+ return null ;
1132+ }
1133+ }
1134+
11301135 @override
11311136 Widget build (BuildContext context) {
1137+ final errorBanner = _errorBanner (context);
1138+ if (errorBanner != null ) {
1139+ return _ComposeBoxContainer (child: errorBanner);
1140+ }
1141+
11321142 final narrow = this .narrow;
11331143 switch (narrow) {
11341144 case ChannelNarrow ():
0 commit comments