Skip to content

Commit f5e8844

Browse files
committed
inbox: Apply stream and topic muting to filter the inbox
1 parent f014ec3 commit f5e8844

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

lib/widgets/inbox.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class _InboxPageState extends State<InboxPage> with PerAccountStoreAwareStateMix
135135
final topicItems = <(String, int, int)>[];
136136
int countInStream = 0;
137137
for (final MapEntry(key: topic, value: messageIds) in topics.entries) {
138+
if (!store.isTopicVisible(streamId, topic)) continue;
138139
final countInTopic = messageIds.length;
139140
topicItems.add((topic, countInTopic, messageIds.last));
140141
countInStream += countInTopic;
@@ -150,9 +151,6 @@ class _InboxPageState extends State<InboxPage> with PerAccountStoreAwareStateMix
150151
sections.add(_StreamSectionData(streamId, countInStream, topicItems));
151152
}
152153

153-
// TODO(#346) Filter out muted messages.
154-
// (Eventually let the user toggle that filtering?)
155-
156154
return Scaffold(
157155
appBar: AppBar(title: const Text('Inbox')),
158156
body: SafeArea(

test/widgets/inbox_test.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,52 @@ void main() {
140140
// TODO test that tapping a conversation row opens the message list
141141
// for the conversation
142142

143+
group('muting', () { // aka topic visibility
144+
testWidgets('baseline', (tester) async {
145+
final stream = eg.stream();
146+
final subscription = eg.subscription(stream);
147+
await setupPage(tester,
148+
streams: [stream],
149+
subscriptions: [subscription],
150+
unreadMessages: [eg.streamMessage(stream: stream, topic: 'lunch')]);
151+
check(tester.widgetList(find.text('lunch'))).length.equals(1);
152+
});
153+
154+
testWidgets('muted topic', (tester) async {
155+
final stream = eg.stream();
156+
final subscription = eg.subscription(stream);
157+
await setupPage(tester,
158+
streams: [stream],
159+
subscriptions: [subscription],
160+
unreadMessages: [eg.streamMessage(stream: stream, topic: 'lunch')]);
161+
store.addUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.muted);
162+
await tester.pump();
163+
check(tester.widgetList(find.text('lunch'))).length.equals(0);
164+
});
165+
166+
testWidgets('muted stream', (tester) async {
167+
final stream = eg.stream();
168+
final subscription = eg.subscription(stream, isMuted: true);
169+
await setupPage(tester,
170+
streams: [stream],
171+
subscriptions: [subscription],
172+
unreadMessages: [eg.streamMessage(stream: stream, topic: 'lunch')]);
173+
check(tester.widgetList(find.text('lunch'))).length.equals(0);
174+
});
175+
176+
testWidgets('unmuted topic in muted stream', (tester) async {
177+
final stream = eg.stream();
178+
final subscription = eg.subscription(stream, isMuted: true);
179+
await setupPage(tester,
180+
streams: [stream],
181+
subscriptions: [subscription],
182+
unreadMessages: [eg.streamMessage(stream: stream, topic: 'lunch')]);
183+
store.addUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.unmuted);
184+
await tester.pump();
185+
check(tester.widgetList(find.text('lunch'))).length.equals(1);
186+
});
187+
});
188+
143189
group('collapsing', () {
144190
Icon findHeaderCollapseIcon(WidgetTester tester, Widget headerRow) {
145191
return tester.widget(

0 commit comments

Comments
 (0)