Skip to content

Commit 87d4762

Browse files
recent dms [nfc]: Add a flag to hide DMs where user can't post
This will be used soon to avoid showing conversations from the recent DMs list where the current user can't post, specifically when a conversation has one or more deactivated user.
1 parent a851146 commit 87d4762

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/widgets/recent_dm_conversations.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import 'unread_count_badge.dart';
1515
import 'user.dart';
1616

1717
class RecentDmConversationsPageBody extends StatefulWidget {
18-
const RecentDmConversationsPageBody({super.key});
18+
const RecentDmConversationsPageBody({
19+
super.key,
20+
this.hideDmsIfUserCantPost = false,
21+
});
22+
23+
final bool hideDmsIfUserCantPost;
1924

2025
@override
2126
State<RecentDmConversationsPageBody> createState() => _RecentDmConversationsPageBodyState();
@@ -76,6 +81,15 @@ class _RecentDmConversationsPageBodyState extends State<RecentDmConversationsPag
7681
// for these conversations we're filtering out?
7782
return SizedBox.shrink();
7883
}
84+
if (widget.hideDmsIfUserCantPost) {
85+
// TODO(#791) handle other cases where user can't post
86+
final hasDeactivatedUser =
87+
narrow.otherRecipientIds.any(
88+
(id) => !(store.getUser(id)?.isActive ?? true));
89+
if (hasDeactivatedUser) {
90+
return SizedBox.shrink();
91+
}
92+
}
7993
return RecentDmConversationsItem(
8094
narrow: narrow,
8195
unreadCount: unreadsModel!.countInDmNarrow(narrow));

0 commit comments

Comments
 (0)