@@ -999,8 +999,21 @@ class _StreamComposeBoxState extends State<_StreamComposeBox> implements Compose
999
999
super .dispose ();
1000
1000
}
1001
1001
1002
+ Widget ? _errorBanner (BuildContext context) {
1003
+ final store = PerAccountStoreWidget .of (context);
1004
+ final selfUser = store.users[store.selfUserId]! ;
1005
+ final channel = store.streams[widget.narrow.streamId]! ;
1006
+ return channel.hasPostingPermission (selfUser, realmWaitingPeriodThreshold: store.realmWaitingPeriodThreshold)
1007
+ ? null : _ErrorBanner (label: ZulipLocalizations .of (context).errorBannerCannotPostInChannelLabel);
1008
+ }
1009
+
1002
1010
@override
1003
1011
Widget build (BuildContext context) {
1012
+ final errorBanner = _errorBanner (context);
1013
+ if (errorBanner != null ) {
1014
+ return _ComposeBoxContainer (child: errorBanner);
1015
+ }
1016
+
1004
1017
return _ComposeBoxLayout (
1005
1018
contentController: _contentController,
1006
1019
contentFocusNode: _contentFocusNode,
@@ -1072,16 +1085,19 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
1072
1085
}
1073
1086
1074
1087
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
- }
1088
+ final store = PerAccountStoreWidget .of (context);
1089
+ switch (widget.narrow) {
1090
+ case TopicNarrow ():
1091
+ final selfUser = store.users[store.selfUserId]! ;
1092
+ final channel = store.streams[(widget.narrow as TopicNarrow ).streamId]! ;
1093
+ return channel.hasPostingPermission (selfUser, realmWaitingPeriodThreshold: store.realmWaitingPeriodThreshold)
1094
+ ? null : _ErrorBanner (label: ZulipLocalizations .of (context).errorBannerCannotPostInChannelLabel);
1095
+ case DmNarrow (: final otherRecipientIds):
1096
+ final hasDeactivatedUser = otherRecipientIds.any ((id) =>
1097
+ ! (store.users[id]? .isActive ?? true ));
1098
+ return hasDeactivatedUser ? _ErrorBanner (label: ZulipLocalizations .of (context)
1099
+ .errorBannerDeactivatedDmLabel) : null ;
1083
1100
}
1084
- return null ;
1085
1101
}
1086
1102
1087
1103
@override
0 commit comments