@@ -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,
@@ -1127,8 +1109,36 @@ class ComposeBox extends StatelessWidget {
1127
1109
}
1128
1110
}
1129
1111
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
+
1130
1135
@override
1131
1136
Widget build (BuildContext context) {
1137
+ final errorBanner = _errorBanner (context);
1138
+ if (errorBanner != null ) {
1139
+ return _ComposeBoxContainer (child: errorBanner);
1140
+ }
1141
+
1132
1142
final narrow = this .narrow;
1133
1143
switch (narrow) {
1134
1144
case ChannelNarrow ():
0 commit comments