Skip to content

Commit 2bc8d72

Browse files
committed
Bound read catch-up and label production gallery profile actions
Signed-off-by: kenny lopez <[email protected]>
1 parent 06535e8 commit 2bc8d72

6 files changed

Lines changed: 116 additions & 54 deletions

File tree

‎mobile/lib/features/channels/channel_detail_page/message_bubble.dart‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,31 @@ class _MessageBubble extends HookConsumerWidget {
391391
bottom: 0,
392392
child: MessageMediaAvatar(
393393
offset: mediaOffset,
394-
child: GestureDetector(
394+
child: Semantics(
395+
container: true,
396+
label: 'Open $displayName profile',
397+
button: true,
398+
excludeSemantics: true,
395399
onTap: () => showUserProfileSheet(
396400
context,
397401
message.pubkey,
398402
names: channelIdentityNamesProvider(
399403
currentChannelId,
400404
),
401405
),
402-
child: _UserAvatar(
403-
profile: profile,
404-
pubkey: message.pubkey,
405-
isAgent: isAgent,
406+
child: GestureDetector(
407+
onTap: () => showUserProfileSheet(
408+
context,
409+
message.pubkey,
410+
names: channelIdentityNamesProvider(
411+
currentChannelId,
412+
),
413+
),
414+
child: _UserAvatar(
415+
profile: profile,
416+
pubkey: message.pubkey,
417+
isAgent: isAgent,
418+
),
406419
),
407420
),
408421
),

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,9 @@ MapEntry<String, int>? _catchUpMark({
108108
);
109109
if (!showsNewest) return null;
110110

111-
// At the live boundary, include hidden huddle endings so their observed
112-
// unread dots clear too. Never advance through replies or past the clock.
113-
var latest = bottom.createdAt;
114-
if (threadRootId == null) {
115-
for (final message in loaded) {
116-
if (message.systemEvent?.type == SystemEventType.huddleEnded &&
117-
message.parentId == null &&
118-
message.createdAt > latest) {
119-
latest = message.createdAt;
120-
}
121-
}
122-
}
123-
final cut = latest < now ? latest : now;
111+
// Never read beyond the last rendered message: a message between that
112+
// row and a hidden lifecycle event may still arrive out of order.
113+
final cut = bottom.createdAt < now ? bottom.createdAt : now;
124114
final key = threadRootId != null
125115
? threadActivityContextKey(threadRootId)
126116
: activityContextKey(channelId);

‎mobile/lib/features/channels/thread_detail_page/thread_message.dart‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,31 @@ class _ThreadMessage extends HookConsumerWidget {
368368
bottom: 0,
369369
child: MessageMediaAvatar(
370370
offset: mediaOffset,
371-
child: GestureDetector(
371+
child: Semantics(
372+
container: true,
373+
label: 'Open $displayName profile',
374+
button: true,
375+
excludeSemantics: true,
372376
onTap: () => showUserProfileSheet(
373377
context,
374378
message.pubkey,
375379
names: channelIdentityNamesProvider(
376380
channelId,
377381
),
378382
),
379-
child: _Avatar(
380-
profile: profile,
381-
pubkey: message.pubkey,
382-
isAgent: isAgent,
383+
child: GestureDetector(
384+
onTap: () => showUserProfileSheet(
385+
context,
386+
message.pubkey,
387+
names: channelIdentityNamesProvider(
388+
channelId,
389+
),
390+
),
391+
child: _Avatar(
392+
profile: profile,
393+
pubkey: message.pubkey,
394+
isAgent: isAgent,
395+
),
383396
),
384397
),
385398
),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,7 @@ void main() {
22112211

22122212
await tester.pump(const Duration(milliseconds: 300));
22132213

2214-
expect(readState.markedContexts, {'activity:$_channelId': 1300});
2214+
expect(readState.markedContexts, {'activity:$_channelId': 1200});
22152215
expect(tester.takeException(), isNull);
22162216
});
22172217

‎mobile/test/features/channels/channel_detail_page_test/review_avatar_tests.dart‎

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ void reviewAvatarTests() {
4949
(tester) async {
5050
final handle = tester.ensureSemantics();
5151
final alice = 'a' * 64;
52-
NostrEvent message(String caption) => _textMsg(
52+
NostrEvent message(String caption, [String second = 'two']) => _textMsg(
5353
id: threadIdRoot,
5454
pubkey: alice,
5555
content:
56-
'$caption\n![One](https://example.com/one.png)\n![Two](https://example.com/two.png)',
56+
'$caption\n![One](https://example.com/one.png)\n![Two](https://example.com/$second.png)',
5757
);
5858
final notifier = _FakeMessagesNotifier([message('Original')]);
5959
await tester.pumpWidget(
@@ -87,7 +87,10 @@ void reviewAvatarTests() {
8787
final avatar = find
8888
.descendant(of: gate, matching: find.byType(AvatarImage))
8989
.first;
90-
final profile = tester.getSemantics(avatar);
90+
final profile = tester.getSemantics(
91+
find.bySemanticsLabel('Open Alice profile'),
92+
);
93+
expect(profile.getSemanticsData().flagsCollection.isButton, isTrue);
9194
expect(
9295
profile.getSemanticsData().hasAction(SemanticsAction.tap),
9396
isTrue,
@@ -151,7 +154,43 @@ void reviewAvatarTests() {
151154
.hasAction(SemanticsAction.tap),
152155
isTrue,
153156
);
157+
controller.jumpToPage(1);
158+
await tester.pumpAndSettle();
159+
notifier.setMessages([message('New media', 'replacement')]);
160+
await tester.pumpAndSettle();
161+
final replacementController =
162+
tester
163+
.widget<CustomScrollView>(
164+
find.descendant(
165+
of: carousel,
166+
matching: find.byType(CustomScrollView),
167+
),
168+
)
169+
.controller!
170+
as PageController;
171+
expect(replacementController.page, 0);
172+
final restored = tester.getSemantics(
173+
find.bySemanticsLabel('Open Alice profile'),
174+
);
175+
expect(restored.getSemanticsData().flagsCollection.isButton, isTrue);
176+
expect(
177+
restored.getSemanticsData().hasAction(SemanticsAction.tap),
178+
isTrue,
179+
);
180+
tester.binding.renderViews.single.owner!.semanticsOwner!.performAction(
181+
restored.id,
182+
SemanticsAction.tap,
183+
);
154184
handle.dispose();
185+
await tester.pumpAndSettle();
186+
expect(find.byType(UserProfileSheet), findsOneWidget);
187+
expect(
188+
find.descendant(
189+
of: find.byType(UserProfileSheet),
190+
matching: find.text('Alice'),
191+
),
192+
findsWidgets,
193+
);
155194
},
156195
);
157196
}

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

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,40 @@ Map<String, int> _marks({
5959
);
6060

6161
void main() {
62-
test(
63-
'hidden endings catch up only at the live boundary and never past now',
64-
() {
65-
final bottom = _msg('visible', 100);
66-
final end = TimelineMessage(
67-
id: 'end',
68-
pubkey: 'alice',
69-
createdAt: 150,
70-
content: '',
71-
systemEvent: const SystemEvent(type: SystemEventType.huddleEnded),
72-
);
73-
Map<String, int> marks(List<TimelineMessage> loaded, int now) =>
74-
readingMarks(
75-
readState: _state(),
76-
channelId: _channel,
77-
isDm: false,
78-
currentPubkey: _self,
79-
loaded: loaded,
80-
visible: [],
81-
bottom: bottom,
82-
now: now,
83-
);
84-
expect(marks([bottom, end], 200)['activity:$_channel'], 150);
85-
expect(marks([bottom, end], 125)['activity:$_channel'], 125);
86-
expect(marks([bottom, _msg('unseen', 120), end], 200), isEmpty);
87-
},
88-
);
62+
test('hidden endings never advance catch-up past the visible row', () {
63+
final bottom = _msg('visible', 100);
64+
final end = TimelineMessage(
65+
id: 'end',
66+
pubkey: 'alice',
67+
createdAt: 150,
68+
content: '',
69+
systemEvent: const SystemEvent(type: SystemEventType.huddleEnded),
70+
);
71+
Map<String, int> marks(List<TimelineMessage> loaded, int now) =>
72+
readingMarks(
73+
readState: _state(),
74+
channelId: _channel,
75+
isDm: false,
76+
currentPubkey: _self,
77+
loaded: loaded,
78+
visible: [],
79+
bottom: bottom,
80+
now: now,
81+
);
82+
expect(marks([bottom, end], 200)['activity:$_channel'], 100);
83+
expect(marks([bottom, end], 125)['activity:$_channel'], 100);
84+
expect(marks([bottom, end], 90)['activity:$_channel'], 90);
85+
expect(marks([bottom, _msg('unseen', 120), end], 200), isEmpty);
86+
final late = _msg('late', 120);
87+
expect(
88+
_marks(
89+
readState: _state(marks([bottom, end], 200)),
90+
loaded: [bottom, late, end],
91+
visible: [late],
92+
),
93+
{'msg:late': 120},
94+
);
95+
});
8996

9097
group('channel timeline', () {
9198
test('the bottom writes one catch-up mark instead of message marks', () {

0 commit comments

Comments
 (0)