Skip to content

Commit a99e7c3

Browse files
committed
fix(mobile): open held reaction tab on Android
Signed-off-by: kenny lopez <[email protected]>
1 parent 9f31a8c commit a99e7c3

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ Future<void> showReactionDetailSheet({
369369
builder: (_) => _AndroidReactionDetailSheet(
370370
channelId: channelId,
371371
reactions: reactions,
372+
initialEmoji: initialEmoji,
372373
),
373374
);
374375
return;
@@ -391,10 +392,12 @@ class _AndroidReactionDetailSheet extends HookConsumerWidget {
391392
const _AndroidReactionDetailSheet({
392393
required this.channelId,
393394
required this.reactions,
395+
required this.initialEmoji,
394396
});
395397

396398
final String channelId;
397399
final List<TimelineReaction> reactions;
400+
final String initialEmoji;
398401

399402
@override
400403
Widget build(BuildContext context, WidgetRef ref) {
@@ -420,6 +423,7 @@ class _AndroidReactionDetailSheet extends HookConsumerWidget {
420423
48.0 + pubkeys.length * 56.0 + MediaQuery.viewPaddingOf(context).bottom;
421424
return DefaultTabController(
422425
length: reactions.length + 1,
426+
initialIndex: reactions.indexWhere((r) => r.emoji == initialEmoji) + 1,
423427
child: SizedBox(
424428
key: const ValueKey('reaction-details-sheet'),
425429
height: desiredHeight.clamp(

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,21 @@ void main() {
373373
await tester.pumpAndSettle();
374374
expect(find.text('Reactions'), findsNothing);
375375
expect(find.text('All 2'), findsOneWidget);
376+
final controller = DefaultTabController.of(
377+
tester.element(find.byType(TabBar)),
378+
);
379+
expect(controller.index, 2);
380+
expect(
381+
find.byKey(ValueKey('reactor-$_alice-$_eyes')).hitTestable(),
382+
findsOneWidget,
383+
);
384+
expect(
385+
find.byKey(ValueKey('reactor-$_alice-$_fire')).hitTestable(),
386+
findsNothing,
387+
);
388+
await tester.tap(find.byKey(const ValueKey('reaction-filter-all')));
389+
await tester.pumpAndSettle();
390+
expect(controller.index, 0);
376391
expect(
377392
find.byKey(ValueKey('reactor-$_alice-$_eyes')).hitTestable(),
378393
findsOneWidget,
@@ -383,6 +398,7 @@ void main() {
383398
);
384399
await tester.tap(find.byKey(const ValueKey('reaction-filter-$_fire')));
385400
await tester.pumpAndSettle();
401+
expect(controller.index, 1);
386402
expect(
387403
find.byKey(ValueKey('reactor-$_alice-$_eyes')).hitTestable(),
388404
findsNothing,
@@ -393,6 +409,7 @@ void main() {
393409
);
394410
await tester.drag(find.byType(TabBarView), const Offset(-500, 0));
395411
await tester.pumpAndSettle();
412+
expect(controller.index, 2);
396413
expect(
397414
find.byKey(ValueKey('reactor-$_alice-$_eyes')).hitTestable(),
398415
findsOneWidget,

0 commit comments

Comments
 (0)