Skip to content

Commit 9e7e41f

Browse files
committed
fix(mobile): include direct replies in deletion uncertainty
Signed-off-by: Tom Brow <[email protected]>
1 parent d3ee9ff commit 9e7e41f

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

‎mobile/lib/features/channels/thread_summary_refresh_queue.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ Map<String, ChannelWindowThreadSummary> lowerBoundSummariesAfterDeletion(
123123
for (final entry in summaries.entries)
124124
if (knownRoots.contains(entry.key) ||
125125
(hasUnknownTarget &&
126-
entry.value.descendantCount > (cached[entry.key] ?? 0)))
126+
math.max(entry.value.replyCount, entry.value.descendantCount) >
127+
(cached[entry.key] ?? 0)))
127128
entry.key: ChannelWindowThreadSummary(
128129
replyCount: math.max(
129130
0,

‎mobile/test/features/channels/channel_messages_provider_test.dart‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4024,6 +4024,80 @@ void main() {
40244024
},
40254025
);
40264026

4027+
for (final lookupFails in [false, true]) {
4028+
test(
4029+
'direct-only broadcast deletion stays uncertain (lookup fails: $lookupFails)',
4030+
() async {
4031+
final session = _RecordingRelaySessionNotifier(
4032+
queryResults: [
4033+
[
4034+
_event(
4035+
id: 'broadcast',
4036+
createdAt: 20,
4037+
extraTags: const [
4038+
['e', 'root', '', 'root'],
4039+
['e', 'root', '', 'reply'],
4040+
['broadcast', '1'],
4041+
],
4042+
),
4043+
_summary(rootId: 'broadcast', replyCount: 1, descendantCount: 0),
4044+
_bounds(),
4045+
],
4046+
if (lookupFails)
4047+
for (var i = 0; i < 3; i++) Exception('ownership unavailable')
4048+
else
4049+
<NostrEvent>[],
4050+
],
4051+
);
4052+
final container = _buildContainer(session);
4053+
addTearDown(container.dispose);
4054+
container.listen(channelMessagesProvider(_channelId), (_, _) {});
4055+
await _pumpEventQueue();
4056+
final notifier = container.read(
4057+
channelMessagesProvider(_channelId).notifier,
4058+
);
4059+
session.emit(
4060+
NostrEvent(
4061+
id: 'delete-evicted-child',
4062+
pubkey: 'author',
4063+
createdAt: 30,
4064+
kind: EventKind.deletion,
4065+
tags: const [
4066+
['h', _channelId],
4067+
['e', 'evicted-child'],
4068+
],
4069+
content: '',
4070+
sig: 'sig',
4071+
),
4072+
);
4073+
expect(notifier.threadSummaries['broadcast']?.isCountPending, isTrue);
4074+
await Future<void>.delayed(
4075+
Duration(milliseconds: lookupFails ? 1800 : 50),
4076+
);
4077+
final entries = buildMainTimelineEntries(
4078+
formatTimeline(
4079+
container.read(channelMessagesProvider(_channelId)).value!,
4080+
),
4081+
relaySummaries: notifier.threadSummaries,
4082+
);
4083+
expect(entries.single.summary?.isCountPending, isTrue);
4084+
expect(entries.single.summary?.isLowerBound, isTrue);
4085+
expect(
4086+
session.queryFilters.where(
4087+
(f) => f.extensions['resolve_thread_roots'] == true,
4088+
),
4089+
hasLength(lookupFails ? 3 : 1),
4090+
);
4091+
expect(
4092+
session.queryFilters.where(
4093+
(f) => f.extensions.containsKey('depth_limit'),
4094+
),
4095+
isEmpty,
4096+
);
4097+
},
4098+
);
4099+
}
4100+
40274101
for (final rootVisible in [false, true]) {
40284102
for (final source in ['known', 'owner', 'live']) {
40294103
for (final survives in [false, true]) {

0 commit comments

Comments
 (0)