Skip to content

Commit 3531217

Browse files
subscription_list [nfc]: Add a flag to hide channels where the user can't post
This will be used soon to avoid showing conversations from the channel list where the current user can't post, specifically when they don't have the permission.
1 parent 5601d0e commit 3531217

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/widgets/subscription_list.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ class SubscriptionListPageBody extends StatefulWidget {
1818
const SubscriptionListPageBody({
1919
super.key,
2020
this.showTopicListButtonInActionSheet = true,
21+
this.hideChannelsIfUserCantPost = false,
2122
});
2223

2324
final bool showTopicListButtonInActionSheet;
25+
final bool hideChannelsIfUserCantPost;
2426

2527
@override
2628
State<SubscriptionListPageBody> createState() => _SubscriptionListPageBodyState();
@@ -90,7 +92,14 @@ class _SubscriptionListPageBodyState extends State<SubscriptionListPageBody> wit
9092

9193
final List<Subscription> pinned = [];
9294
final List<Subscription> unpinned = [];
95+
final now = DateTime.now();
9396
for (final subscription in store.subscriptions.values) {
97+
if (widget.hideChannelsIfUserCantPost) {
98+
if (!store.hasPostingPermission(inChannel: subscription,
99+
user: store.selfUser, byDate: now)) {
100+
continue;
101+
}
102+
}
94103
if (subscription.pinToTop) {
95104
pinned.add(subscription);
96105
} else {

0 commit comments

Comments
 (0)