@@ -1071,26 +1071,8 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
1071
1071
super .dispose ();
1072
1072
}
1073
1073
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
-
1087
1074
@override
1088
1075
Widget build (BuildContext context) {
1089
- final errorBanner = _errorBanner (context);
1090
- if (errorBanner != null ) {
1091
- return _ComposeBoxContainer (child: errorBanner);
1092
- }
1093
-
1094
1076
return _ComposeBoxLayout (
1095
1077
contentController: _contentController,
1096
1078
contentFocusNode: _contentFocusNode,
@@ -1128,8 +1110,37 @@ class ComposeBox extends StatelessWidget {
1128
1110
}
1129
1111
}
1130
1112
1113
+ Widget ? _errorBanner (BuildContext context) {
1114
+ final store = PerAccountStoreWidget .of (context);
1115
+ final selfUser = store.users[store.selfUserId]! ;
1116
+ switch (narrow) {
1117
+ case ChannelNarrow narrow:
1118
+ final channel = store.streams[narrow.streamId]! ;
1119
+ return channel.hasPostingPermission (selfUser, byDate: DateTime .now (), realmWaitingPeriodThreshold: store.realmWaitingPeriodThreshold)
1120
+ ? null : _ErrorBanner (label: ZulipLocalizations .of (context).errorBannerCannotPostInChannelLabel);
1121
+ case TopicNarrow narrow:
1122
+ final channel = store.streams[narrow.streamId]! ;
1123
+ return channel.hasPostingPermission (selfUser, byDate: DateTime .now (), realmWaitingPeriodThreshold: store.realmWaitingPeriodThreshold)
1124
+ ? null : _ErrorBanner (label: ZulipLocalizations .of (context).errorBannerCannotPostInChannelLabel);
1125
+ case DmNarrow (: final otherRecipientIds):
1126
+ final hasDeactivatedUser = otherRecipientIds.any ((id) =>
1127
+ ! (store.users[id]? .isActive ?? true ));
1128
+ return hasDeactivatedUser ? _ErrorBanner (label: ZulipLocalizations .of (context)
1129
+ .errorBannerDeactivatedDmLabel) : null ;
1130
+ case CombinedFeedNarrow ():
1131
+ case MentionsNarrow ():
1132
+ case StarredMessagesNarrow ():
1133
+ return null ;
1134
+ }
1135
+ }
1136
+
1131
1137
@override
1132
1138
Widget build (BuildContext context) {
1139
+ final errorBanner = _errorBanner (context);
1140
+ if (errorBanner != null ) {
1141
+ return _ComposeBoxContainer (child: errorBanner);
1142
+ }
1143
+
1133
1144
final narrow = this .narrow;
1134
1145
switch (narrow) {
1135
1146
case ChannelNarrow ():
0 commit comments