Skip to content

Commit 28b927e

Browse files
square-tombstudioclaude
committed
fix(mobile): let the synced marker catch up after filtered reads
Advance a filtered row's thread or channel marker through every event that is now read, not just up to the row's own latest event, so replies read under one filter sync once the hidden ones are read under another. Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Tom Brow <[email protected]>
1 parent d17f79a commit 28b927e

2 files changed

Lines changed: 29 additions & 17 deletions

File tree

‎mobile/lib/features/activity/activity_page.dart‎

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:buzz/shared/widgets/feedback_snackbar.dart';
22

33
import 'dart:async';
4-
import 'dart:math' show max, min;
4+
import 'dart:math' show max;
55

66
import '../../shared/widgets/ios_message_create_button.dart';
77
import '../../shared/widgets/ios_glass_navigation_button.dart';
@@ -213,9 +213,11 @@ class ActivityPage extends HookConsumerWidget {
213213
return null;
214214
}, [preloadPubkeysKey]);
215215

216-
// A filtered row holds only part of its conversation. Advance its synced
217-
// thread or channel marker only up to the first unread event the filter
218-
// hides, and give shown events past that point local per-message marks.
216+
// A filtered row holds only part of its conversation. Its synced thread
217+
// or channel marker is one watermark, so advance it through every event
218+
// that is now read (shown here, or already read) and stop just before the
219+
// first unread event the filter hides. Shown events past that point get
220+
// local per-message marks until the hidden one is read too.
219221
void markPartialRowRead(
220222
InboxItem item,
221223
String channelId, {
@@ -231,21 +233,30 @@ class ActivityPage extends HookConsumerWidget {
231233
(rootId == null ||
232234
(isThreadReply(e.tags) &&
233235
threadReferenceOf(e.tags).rootId == rootId));
234-
var cap = item.latestActivityAt;
235-
for (final e in allItems.expand((i) => i.groupItems)) {
236-
if (shown.containsKey(e.id) ||
237-
!inContext(e) ||
238-
isInboxEventRead(e, markerOf: markerOf)) {
239-
continue;
236+
final events = {
237+
for (final e in [
238+
...allItems.expand((i) => i.groupItems),
239+
...shown.values,
240+
])
241+
if (inContext(e)) e.id: e,
242+
}.values.toList()..sort((a, b) => a.createdAt.compareTo(b.createdAt));
243+
int? cap;
244+
for (final e in events) {
245+
if (!shown.containsKey(e.id) &&
246+
!isInboxEventRead(e, markerOf: markerOf)) {
247+
cap = e.createdAt - 1;
248+
break;
240249
}
241-
cap = min(cap, e.createdAt - 1);
250+
cap = e.createdAt;
251+
}
252+
if (cap != null) {
253+
notifier.markContextRead(
254+
rootId == null ? channelId : threadContextKey(rootId),
255+
cap,
256+
);
242257
}
243-
notifier.markContextRead(
244-
rootId == null ? channelId : threadContextKey(rootId),
245-
cap,
246-
);
247258
for (final e in shown.values) {
248-
if (inContext(e) && e.createdAt <= cap) continue;
259+
if (inContext(e) && cap != null && e.createdAt <= cap) continue;
249260
notifier.markContextRead(msgContextKey(e.id), e.createdAt);
250261
}
251262
}

‎mobile/test/features/activity/activity_page_test.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,8 @@ void main() {
943943
const Offset(-500, 0),
944944
);
945945
await tester.pumpAndSettle();
946-
expect(threadMarker(), now - 300);
946+
// With the agent reply read too, the synced marker covers both.
947+
expect(threadMarker(), now - 200);
947948
await chooseSender('Anyone');
948949
expect(find.byKey(const ValueKey('inbox-unread-dot-p1')), findsNothing);
949950
},

0 commit comments

Comments
 (0)