Skip to content

Commit ef6dcf6

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 005f700 commit ef6dcf6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/widgets/recent_dm_conversations.dart

Lines changed: 14 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,14 @@ class _RecentDmConversationsPageBodyState extends State<RecentDmConversationsPag
7681
// for these conversations we're filtering out?
7782
return SizedBox.shrink();
7883
}
84+
if (widget.hideDmsIfUserCantPost) {
85+
final hasDeactivatedUser =
86+
narrow.otherRecipientIds.any(
87+
(id) => !(store.getUser(id)?.isActive ?? true));
88+
if (hasDeactivatedUser) {
89+
return SizedBox.shrink();
90+
}
91+
}
7992
return RecentDmConversationsItem(
8093
narrow: narrow,
8194
unreadCount: unreadsModel!.countInDmNarrow(narrow));

0 commit comments

Comments
 (0)