@openpeepshq/rn-components 0.14.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/package.json +3 -3
  2. package/src/components/buttonOverflow.test.tsx +8 -0
  3. package/src/components/conversations/ConversationParticipantsModal.tsx +1 -6
  4. package/src/components/icons/index.ts +2 -0
  5. package/src/components/jams/JamChatDrawer.test.tsx +263 -0
  6. package/src/components/jams/JamChatDrawer.tsx +117 -52
  7. package/src/components/jams/JamConference.tsx +5 -0
  8. package/src/components/jams/JamParticipantConference.tsx +7 -4
  9. package/src/components/jams/JamPeopleDrawer.test.tsx +216 -0
  10. package/src/components/jams/JamPeopleDrawer.tsx +32 -2
  11. package/src/components/jams/JamRoomIndicators.test.tsx +190 -38
  12. package/src/components/jams/JamRoomIndicators.tsx +62 -20
  13. package/src/components/jams/useTrackSubscriptionBump.test.ts +294 -0
  14. package/src/components/jams/useTrackSubscriptionBump.ts +44 -0
  15. package/src/components/navigation/nativeRouter.tsx +13 -3
  16. package/src/components/notifications/NotificationHeaderActions.test.tsx +285 -0
  17. package/src/components/notifications/NotificationHeaderActions.tsx +91 -4
  18. package/src/components/notifications/NotificationsList.test.tsx +109 -0
  19. package/src/components/notifications/NotificationsList.tsx +13 -3
  20. package/src/components/notifications/types/Reaction.tsx +6 -2
  21. package/src/components/post/feed/events/EventsCalendar.test.tsx +33 -18
  22. package/src/components/post/pieces/PostActions.test.tsx +244 -0
  23. package/src/components/post/pieces/PostActions.tsx +74 -49
  24. package/src/components/post/pieces/ReactionPicker.test.tsx +184 -0
  25. package/src/components/post/pieces/ReactionPicker.tsx +58 -0
  26. package/src/components/post/pieces/ShareMenu.test.tsx +217 -0
  27. package/src/components/post/pieces/ShareMenu.tsx +107 -61
  28. package/src/components/post/pieces/index.ts +1 -0
  29. package/src/components/post/pieces/modals/ReactionsModal.tsx +1 -1
  30. package/src/components/post/post-form/VisibilitySheet.test.tsx +153 -0
  31. package/src/components/post/post-form/VisibilitySheet.tsx +6 -5
  32. package/src/components/profile/Avatar.test.tsx +147 -0
  33. package/src/components/profile/Avatar.tsx +26 -0
  34. package/src/components/profile/ProfileCard.test.tsx +165 -8
  35. package/src/components/profile/ProfileCard.tsx +63 -10
  36. package/src/components/profile/ProfileSelector.test.tsx +147 -5
  37. package/src/components/profile/ProfileSelector.tsx +64 -18
  38. package/src/pages/Notifications.tsx +3 -1
  39. package/src/pages/Welcome.test.tsx +166 -0
  40. package/src/pages/Welcome.tsx +50 -4
  41. package/src/pages/conversations/New.test.tsx +340 -0
  42. package/src/pages/conversations/New.tsx +35 -30
  43. package/src/pages/events/Index.tsx +4 -1
  44. package/src/pages/events/My.tsx +1 -1
  45. package/src/pages/groups/Show.tsx +1 -1
  46. package/src/theme/useThemeOpacity.test.ts +70 -0
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Regression tests for the RN notification type-filter sheet (issue #354).
3
+ *
4
+ * The web `NotificationHeaderActions` already pins its filter menu; the RN
5
+ * sheet is the one rendering layer the shared-hook test cannot see (it renders
6
+ * rows from the `useNotificationFeedFilter` data and drives `toggle`/`showAll`
7
+ * from row presses). These lock in the RN-only wiring: one checkbox row per
8
+ * type with `accessibilityState.checked` from `isHidden`, cumulative toggles,
9
+ * and the conditional "Show all types" footer that clears the filter.
10
+ *
11
+ * External imports are mocked (node jest env, no native modules) — the sheet
12
+ * primitive renders its `data` rows inline so they are inspectable.
13
+ */
14
+ import React from 'react';
15
+ import ReactTestRenderer from 'react-test-renderer';
16
+ import { NotificationHeaderActions } from './NotificationHeaderActions';
17
+
18
+ // --- shared mutable state (mock* prefix is hoisting-safe) -------------------
19
+ const TYPES = [{ type: 'repost' }, { type: 'reaction' }, { type: 'pollVote' }];
20
+ let mockHidden: Set<string> = new Set();
21
+ const mockToggle = jest.fn(async (type: string) => {
22
+ if (mockHidden.has(type)) mockHidden.delete(type);
23
+ else mockHidden.add(type);
24
+ });
25
+ const mockShowAll = jest.fn(async () => {
26
+ mockHidden = new Set();
27
+ });
28
+ const mockMarkAllSeen = jest.fn(async (_path?: unknown, _q?: unknown) => {});
29
+
30
+ jest.mock('react-native', () => {
31
+ const React = require('react');
32
+ const make = (tag: string) => (props: { children?: React.ReactNode }) =>
33
+ React.createElement(tag, props, props.children);
34
+ return {
35
+ View: make('View'),
36
+ Pressable: make('Pressable'),
37
+ Text: make('Text'),
38
+ };
39
+ });
40
+
41
+ jest.mock('react-i18next', () => ({
42
+ useTranslation: () => ({
43
+ t: (key: string, opts?: { defaultValue?: string }) =>
44
+ opts?.defaultValue ?? key,
45
+ }),
46
+ }));
47
+
48
+ jest.mock('react-native-toast-message', () => ({
49
+ __esModule: true,
50
+ default: { show: jest.fn() },
51
+ }));
52
+
53
+ jest.mock('@react-navigation/native', () => ({
54
+ useNavigation: () => ({ navigate: jest.fn() }),
55
+ }));
56
+
57
+ jest.mock('@openpeepshq/react', () => ({
58
+ useOpenpeeps: () => ({
59
+ openpeepsApi: {
60
+ // Returns the endpoint function directly (not an async wrapper) so the
61
+ // test can assert the args `markAllRead` forwards to it — the wiring
62
+ // that encodes the approved mark-all split (visible types only).
63
+ markAllNotificationsAsSeenAction: () => () => mockMarkAllSeen,
64
+ },
65
+ queryClient: {},
66
+ }),
67
+ markCachedNotificationsSeen: () => {},
68
+ useNotificationFeedFilter: () => ({
69
+ types: TYPES,
70
+ hiddenTypes: mockHidden,
71
+ isHidden: (type: string) => mockHidden.has(type),
72
+ toggle: mockToggle,
73
+ showAll: mockShowAll,
74
+ hasFilter: mockHidden.size > 0,
75
+ excludeTypes: mockHidden.size
76
+ ? [...mockHidden].sort().join(',')
77
+ : undefined,
78
+ }),
79
+ }));
80
+
81
+ jest.mock('../icons/index', () => {
82
+ const React = require('react');
83
+ const icon = (name: string) => () => React.createElement(name);
84
+ return {
85
+ CheckCheckIcon: icon('CheckCheckIcon'),
86
+ Settings2Icon: icon('Settings2Icon'),
87
+ SlidersHorizontalIcon: icon('SlidersHorizontalIcon'),
88
+ };
89
+ });
90
+
91
+ jest.mock('../ui/button', () => {
92
+ const React = require('react');
93
+ return {
94
+ Button: (props: { children?: React.ReactNode }) =>
95
+ React.createElement('Button', props, props.children),
96
+ };
97
+ });
98
+
99
+ jest.mock('../ui/checkbox', () => {
100
+ const React = require('react');
101
+ return {
102
+ Checkbox: (props: Record<string, unknown>) =>
103
+ React.createElement('Checkbox', props),
104
+ };
105
+ });
106
+
107
+ jest.mock('../ui/themed-text', () => {
108
+ const React = require('react');
109
+ return {
110
+ ThemedText: (props: { children?: React.ReactNode }) =>
111
+ React.createElement('ThemedText', props, props.children),
112
+ };
113
+ });
114
+
115
+ jest.mock('../ui/bottom-sheet', () => {
116
+ const React = require('react');
117
+ const passThrough =
118
+ (tag: string) => (props: { children?: React.ReactNode }) =>
119
+ React.createElement(tag, props, props.children);
120
+ return {
121
+ BottomSheet: passThrough('BottomSheet'),
122
+ BottomSheetContent: passThrough('BottomSheetContent'),
123
+ BottomSheetHeader: passThrough('BottomSheetHeader'),
124
+ // Render `data` rows inline (plus the footer) so the sheet's contents are
125
+ // inspectable without a native ScrollView/FlatList.
126
+ BottomSheetFlatList: (props: {
127
+ data?: Array<{ type: string }>;
128
+ renderItem: (p: {
129
+ item: { type: string };
130
+ index: number;
131
+ }) => React.ReactNode;
132
+ ListFooterComponent?: React.ReactNode;
133
+ }) =>
134
+ React.createElement(
135
+ 'BottomSheetFlatList',
136
+ null,
137
+ (props.data ?? []).map((item, index) =>
138
+ React.createElement(
139
+ 'View',
140
+ { key: index },
141
+ props.renderItem({ item, index })
142
+ )
143
+ ),
144
+ props.ListFooterComponent
145
+ ),
146
+ useBottomSheet: () => ({
147
+ ref: { current: { present: jest.fn(), dismiss: jest.fn() } },
148
+ open: jest.fn(),
149
+ close: jest.fn(),
150
+ }),
151
+ };
152
+ });
153
+
154
+ const render = () => {
155
+ let tree!: ReactTestRenderer.ReactTestRenderer;
156
+ ReactTestRenderer.act(() => {
157
+ tree = ReactTestRenderer.create(
158
+ React.createElement(NotificationHeaderActions)
159
+ );
160
+ });
161
+ return tree;
162
+ };
163
+
164
+ // The row Pressables carry `accessibilityRole="checkbox"`; the header Buttons
165
+ // and the "Show all types" footer do not, so this isolates the type rows.
166
+ const rows = (tree: ReactTestRenderer.ReactTestRenderer) =>
167
+ tree.root
168
+ .findAllByType('Pressable')
169
+ .filter((p) => p.props.accessibilityRole === 'checkbox');
170
+ const showAllRow = (tree: ReactTestRenderer.ReactTestRenderer) =>
171
+ tree.root
172
+ .findAllByType('Pressable')
173
+ .find((p) => p.props.accessibilityRole !== 'checkbox');
174
+ // The header's first Button is "Mark all as read" (its onPress drives
175
+ // markAllRead); the i18n mock resolves its label to the raw key.
176
+ const markAllReadButton = (tree: ReactTestRenderer.ReactTestRenderer) =>
177
+ tree.root
178
+ .findAllByType('Button')
179
+ .find(
180
+ (b) =>
181
+ b.props.accessibilityLabel ===
182
+ 'settings.notifications.feedPreferences.markAllRead'
183
+ );
184
+
185
+ describe('NotificationHeaderActions (RN filter sheet)', () => {
186
+ beforeEach(() => {
187
+ mockHidden = new Set();
188
+ mockToggle.mockClear();
189
+ mockShowAll.mockClear();
190
+ mockMarkAllSeen.mockClear();
191
+ });
192
+
193
+ it('pins one checkbox row per type with checked state from isHidden', () => {
194
+ mockHidden = new Set(['reaction']);
195
+ const tree = render();
196
+ // repost, reaction (hidden), pollVote
197
+ expect(rows(tree).map((r) => r.props.accessibilityState.checked)).toEqual([
198
+ true,
199
+ false,
200
+ true,
201
+ ]);
202
+ });
203
+
204
+ it('applies cumulative toggles, each flipping only its own row', () => {
205
+ const tree = render();
206
+ const first = rows(tree);
207
+ ReactTestRenderer.act(() => {
208
+ first[0].props.onPress();
209
+ });
210
+ expect(mockToggle).toHaveBeenCalledWith('repost');
211
+ tree.unmount();
212
+
213
+ // Re-render against the updated hidden set: repost is now hidden.
214
+ const tree2 = render();
215
+ expect(rows(tree2).map((r) => r.props.accessibilityState.checked)).toEqual([
216
+ false,
217
+ true,
218
+ true,
219
+ ]);
220
+ ReactTestRenderer.act(() => {
221
+ rows(tree2)[1].props.onPress();
222
+ });
223
+ expect(mockToggle).toHaveBeenLastCalledWith('reaction');
224
+ tree2.unmount();
225
+
226
+ const tree3 = render();
227
+ expect(rows(tree3).map((r) => r.props.accessibilityState.checked)).toEqual([
228
+ false,
229
+ false,
230
+ true,
231
+ ]);
232
+ tree3.unmount();
233
+ });
234
+
235
+ it('omits "Show all types" while nothing is hidden', () => {
236
+ const tree = render();
237
+ expect(showAllRow(tree)).toBeUndefined();
238
+ });
239
+
240
+ it('shows "Show all types" when filtered, and clearing unhides everything', () => {
241
+ mockHidden = new Set(['repost', 'pollVote']);
242
+ const tree = render();
243
+ const footer = showAllRow(tree);
244
+ expect(footer).toBeDefined();
245
+
246
+ ReactTestRenderer.act(() => {
247
+ footer!.props.onPress();
248
+ });
249
+ expect(mockShowAll).toHaveBeenCalled();
250
+ tree.unmount();
251
+
252
+ const tree2 = render();
253
+ expect(showAllRow(tree2)).toBeUndefined();
254
+ expect(rows(tree2).map((r) => r.props.accessibilityState.checked)).toEqual([
255
+ true,
256
+ true,
257
+ true,
258
+ ]);
259
+ tree2.unmount();
260
+ });
261
+
262
+ it('mark-all-read passes the active filter as excludeTypes', () => {
263
+ mockHidden = new Set(['repost', 'reaction']);
264
+ const tree = render();
265
+ ReactTestRenderer.act(() => {
266
+ markAllReadButton(tree)!.props.onPress();
267
+ });
268
+ expect(mockMarkAllSeen).toHaveBeenCalledTimes(1);
269
+ // Sorted + comma-joined, exactly as the feed query and server schema expect.
270
+ expect(mockMarkAllSeen).toHaveBeenCalledWith(undefined, {
271
+ excludeTypes: 'reaction,repost',
272
+ });
273
+ tree.unmount();
274
+ });
275
+
276
+ it('mark-all-read passes no query params when nothing is filtered', () => {
277
+ const tree = render();
278
+ ReactTestRenderer.act(() => {
279
+ markAllReadButton(tree)!.props.onPress();
280
+ });
281
+ expect(mockMarkAllSeen).toHaveBeenCalledTimes(1);
282
+ expect(mockMarkAllSeen).toHaveBeenCalledWith(undefined, undefined);
283
+ tree.unmount();
284
+ });
285
+ });
@@ -1,25 +1,51 @@
1
1
  import React from 'react';
2
- import { View } from 'react-native';
2
+ import { Pressable, View } from 'react-native';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import Toast from 'react-native-toast-message';
5
5
  import { useNavigation } from '@react-navigation/native';
6
6
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
7
- import { markCachedNotificationsSeen, useOpenpeeps } from '@openpeepshq/react';
8
- import { CheckCheckIcon, Settings2Icon } from '../icons/index';
7
+ import type { NotificationType } from '@openpeepshq/common';
8
+ import {
9
+ markCachedNotificationsSeen,
10
+ useNotificationFeedFilter,
11
+ useOpenpeeps,
12
+ } from '@openpeepshq/react';
13
+ import {
14
+ CheckCheckIcon,
15
+ Settings2Icon,
16
+ SlidersHorizontalIcon,
17
+ } from '../icons/index';
9
18
  import { MainStackParamList } from '../navigation/types/index';
10
19
  import { Button } from '../ui/button';
20
+ import {
21
+ BottomSheet,
22
+ BottomSheetContent,
23
+ BottomSheetFlatList,
24
+ BottomSheetHeader,
25
+ useBottomSheet,
26
+ } from '../ui/bottom-sheet';
27
+ import { Checkbox } from '../ui/checkbox';
28
+ import { ThemedText } from '../ui/themed-text';
11
29
 
12
30
  export const NotificationHeaderActions = () => {
13
31
  const { t } = useTranslation();
14
32
  const { openpeepsApi, queryClient } = useOpenpeeps();
15
33
  const navigation =
16
34
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
35
+ const filter = useNotificationFeedFilter();
36
+ const filterSheet = useBottomSheet();
17
37
  const markAllNotificationsAsSeen =
18
38
  openpeepsApi.markAllNotificationsAsSeenAction()();
19
39
 
20
40
  const markAllRead = async () => {
21
41
  try {
22
- await markAllNotificationsAsSeen();
42
+ // Cover only what is visible under the active filter; hidden types are
43
+ // left untouched (the feed never shows them, so they can't be "read").
44
+ // The first arg is the (absent) path-params slot.
45
+ await markAllNotificationsAsSeen(
46
+ undefined,
47
+ filter.hasFilter ? { excludeTypes: filter.excludeTypes } : undefined
48
+ );
23
49
  markCachedNotificationsSeen(queryClient);
24
50
  Toast.show({
25
51
  type: 'success',
@@ -30,6 +56,8 @@ export const NotificationHeaderActions = () => {
30
56
  }
31
57
  };
32
58
 
59
+ const filterTitle = t('notification.filter.title');
60
+
33
61
  return (
34
62
  <View className="flex-row gap-x-2">
35
63
  <Button
@@ -42,6 +70,14 @@ export const NotificationHeaderActions = () => {
42
70
  >
43
71
  <CheckCheckIcon size={18} className="text-foreground" />
44
72
  </Button>
73
+ <Button
74
+ size="icon"
75
+ variant="outline"
76
+ accessibilityLabel={filterTitle}
77
+ onPress={filterSheet.open}
78
+ >
79
+ <SlidersHorizontalIcon size={18} className="text-foreground" />
80
+ </Button>
45
81
  <Button
46
82
  size="icon"
47
83
  variant="outline"
@@ -50,6 +86,57 @@ export const NotificationHeaderActions = () => {
50
86
  >
51
87
  <Settings2Icon size={18} className="text-foreground" />
52
88
  </Button>
89
+
90
+ <BottomSheet>
91
+ <BottomSheetContent ref={filterSheet.ref} snapPoints={['70%']}>
92
+ <BottomSheetHeader className="border-b-0">
93
+ <ThemedText className="text-base font-semibold">
94
+ {filterTitle}
95
+ </ThemedText>
96
+ </BottomSheetHeader>
97
+ <BottomSheetFlatList
98
+ className="py-0"
99
+ contentContainerStyle={{ paddingVertical: 0 }}
100
+ data={filter.types}
101
+ keyExtractor={(nt) => (nt as NotificationType).type}
102
+ renderItem={({ item }) => {
103
+ const nt = item as NotificationType;
104
+ return (
105
+ <Pressable
106
+ accessibilityRole="checkbox"
107
+ accessibilityState={{ checked: !filter.isHidden(nt.type) }}
108
+ onPress={() => void filter.toggle(nt.type)}
109
+ className="flex-row items-center gap-2 py-2"
110
+ >
111
+ <Checkbox
112
+ checked={!filter.isHidden(nt.type)}
113
+ // The row is the toggle; the checkbox is display-only.
114
+ pointerEvents="none"
115
+ onCheckedChange={() => {}}
116
+ />
117
+ <ThemedText className="flex-1">
118
+ {t(`settings.notifications.types.${nt.type}.label`, {
119
+ defaultValue: nt.type,
120
+ })}
121
+ </ThemedText>
122
+ </Pressable>
123
+ );
124
+ }}
125
+ ListFooterComponent={
126
+ filter.hasFilter ? (
127
+ <Pressable
128
+ onPress={() => void filter.showAll()}
129
+ className="flex-row items-center py-2"
130
+ >
131
+ <ThemedText className="text-primary">
132
+ {t('notification.filter.showAll')}
133
+ </ThemedText>
134
+ </Pressable>
135
+ ) : null
136
+ }
137
+ />
138
+ </BottomSheetContent>
139
+ </BottomSheet>
53
140
  </View>
54
141
  );
55
142
  };
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Pins the RN `NotificationsList` empty-state copy (issue #354, round-8
3
+ * suggestion 2): with an active type filter the empty feed shows the
4
+ * `notification.emptyFiltered` copy, otherwise `notification.empty`. The feed
5
+ * filters server-side via `excludeTypes`, so both branches are reachable from
6
+ * the client.
7
+ */
8
+ import React from 'react';
9
+ import ReactTestRenderer from 'react-test-renderer';
10
+ import { NotificationsList } from './NotificationsList';
11
+
12
+ let mockHasFilter = false;
13
+ let mockExcludeTypes: string | undefined;
14
+ const mockEmptyCalls: Array<{ copyKey: string }> = [];
15
+
16
+ jest.mock('react-native', () => ({
17
+ ScrollView: (props: { children?: React.ReactNode }) =>
18
+ React.createElement('ScrollView', null, props.children),
19
+ RefreshControl: (props: Record<string, unknown>) =>
20
+ React.createElement('RefreshControl', props),
21
+ ActivityIndicator: () => null,
22
+ }));
23
+
24
+ jest.mock('@react-navigation/native', () => ({
25
+ useFocusEffect: () => {},
26
+ }));
27
+
28
+ jest.mock('@openpeepshq/react', () => ({
29
+ useOpenpeeps: () => ({
30
+ openpeepsApi: {
31
+ useCurrentProfileNotifications: () => ({
32
+ data: { pages: [] },
33
+ isLoading: false,
34
+ refetch: async () => {},
35
+ }),
36
+ },
37
+ }),
38
+ useNotificationFeedFilter: () => ({
39
+ hasFilter: mockHasFilter,
40
+ excludeTypes: mockExcludeTypes,
41
+ }),
42
+ }));
43
+
44
+ jest.mock('../../lib/utils', () => ({
45
+ handleScroll: () => {},
46
+ }));
47
+
48
+ jest.mock('../custom/common/empty-state-container', () => {
49
+ // Rendered as a component type (not a host tag) so the props actually reach
50
+ // the mock body, which records the `copyKey` the list selected.
51
+ const MockEmpty = (props: { copyKey: string; defaultValue?: string }) => {
52
+ mockEmptyCalls.push(props);
53
+ return React.createElement('EmptyStateContainer', null, props.copyKey);
54
+ };
55
+ return { EmptyStateContainer: MockEmpty };
56
+ });
57
+
58
+ jest.mock('./NotificationItem', () => ({
59
+ NotificationItem: () => null,
60
+ }));
61
+
62
+ // An empty feed query: no items, not loading, no further pages.
63
+ const emptyQuery = {
64
+ data: { pages: [] },
65
+ isLoading: false,
66
+ isFetchingNextPage: false,
67
+ hasNextPage: false,
68
+ refetch: async () => {},
69
+ fetchNextPage: async () => {},
70
+ };
71
+
72
+ describe('NotificationsList (RN empty state)', () => {
73
+ beforeEach(() => {
74
+ mockHasFilter = false;
75
+ mockExcludeTypes = undefined;
76
+ mockEmptyCalls.length = 0;
77
+ });
78
+
79
+ const render = () => {
80
+ let tree!: ReactTestRenderer.ReactTestRenderer;
81
+ ReactTestRenderer.act(() => {
82
+ tree = ReactTestRenderer.create(
83
+ React.createElement(NotificationsList, {
84
+ query: emptyQuery as never,
85
+ isNotificationFeed: false,
86
+ })
87
+ );
88
+ });
89
+ return tree;
90
+ };
91
+
92
+ it('shows the plain empty copy when nothing is filtered', () => {
93
+ const tree = render();
94
+ expect(mockEmptyCalls).toEqual([
95
+ expect.objectContaining({ copyKey: 'notification.empty' }),
96
+ ]);
97
+ tree.unmount();
98
+ });
99
+
100
+ it('shows the filtered empty copy when a type filter is active', () => {
101
+ mockHasFilter = true;
102
+ mockExcludeTypes = 'repost';
103
+ const tree = render();
104
+ expect(mockEmptyCalls).toEqual([
105
+ expect.objectContaining({ copyKey: 'notification.emptyFiltered' }),
106
+ ]);
107
+ tree.unmount();
108
+ });
109
+ });
@@ -2,7 +2,7 @@ import { ScrollView, RefreshControl, ActivityIndicator } from 'react-native';
2
2
  import React from 'react';
3
3
  import type { PublicNotification } from '@openpeepshq/common';
4
4
  import { useFocusEffect } from '@react-navigation/native';
5
- import { useOpenpeeps } from '@openpeepshq/react';
5
+ import { useNotificationFeedFilter, useOpenpeeps } from '@openpeepshq/react';
6
6
  import { handleScroll } from '../../lib/utils';
7
7
  import { EmptyStateContainer } from '../custom/common/empty-state-container';
8
8
  import { NotificationItem } from './NotificationItem';
@@ -24,8 +24,10 @@ export const NotificationsList = ({
24
24
  onRefresh,
25
25
  }: NotificationsListProps) => {
26
26
  const { openpeepsApi } = useOpenpeeps();
27
+ const { hasFilter, excludeTypes } = useNotificationFeedFilter();
27
28
  const internalQuery = openpeepsApi.useCurrentProfileNotifications({
28
29
  limit: pageSize,
30
+ excludeTypes,
29
31
  });
30
32
  const query = externalQuery ?? internalQuery;
31
33
 
@@ -33,6 +35,8 @@ export const NotificationsList = ({
33
35
  const refetchRef = React.useRef(query.refetch);
34
36
  refetchRef.current = query.refetch;
35
37
 
38
+ // Hidden types are excluded server-side (`excludeTypes`), so scroll-
39
+ // triggered pagination pages through visible items only.
36
40
  const allNotifications = React.useMemo(() => {
37
41
  if (!query.data?.pages) {
38
42
  return [];
@@ -74,8 +78,14 @@ export const NotificationsList = ({
74
78
  ) : (
75
79
  <EmptyStateContainer
76
80
  type="notifications"
77
- copyKey="notification.empty"
78
- defaultValue="No notifications"
81
+ copyKey={
82
+ hasFilter ? 'notification.emptyFiltered' : 'notification.empty'
83
+ }
84
+ defaultValue={
85
+ hasFilter
86
+ ? 'No notifications of the selected types'
87
+ : 'No notifications'
88
+ }
79
89
  />
80
90
  )}
81
91
  </>
@@ -2,7 +2,7 @@ import { Pressable, View } from 'react-native';
2
2
  import React from 'react';
3
3
  import { ThemedText } from '../../ui/themed-text';
4
4
  import { NotificationWrapper } from '../NotificationWrapper';
5
- import { PublicNotification } from '@openpeepshq/common';
5
+ import { PublicNotification, AP_LIKE_REACTION } from '@openpeepshq/common';
6
6
  import { profileName } from '../../../lib/utils';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { MainStackParamList } from '../../navigation/types/index';
@@ -19,6 +19,10 @@ export const Reaction: React.FC<NotificationTypeProps> = ({ notification }) => {
19
19
  const { t } = useTranslation();
20
20
  const navigation =
21
21
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
22
+ // Render the stored reaction (parity with the web TypedNotification); fall
23
+ // back to the legacy plain like for old notifications without a reaction.
24
+ const reaction =
25
+ (notification.data as { reaction?: string })?.reaction ?? AP_LIKE_REACTION;
22
26
 
23
27
  return (
24
28
  <NotificationWrapper
@@ -34,7 +38,7 @@ export const Reaction: React.FC<NotificationTypeProps> = ({ notification }) => {
34
38
  >
35
39
  <View className="flex w-full items-center justify-between">
36
40
  <View className="mb-2 flex flex-row items-center gap-2 font-semibold flex-wrap">
37
- <ThemedText>👍🏽</ThemedText>
41
+ <ThemedText>{reaction}</ThemedText>
38
42
  <ThemedText>
39
43
  {t('notification.reaction.text', {
40
44
  profileName: profileName(profile),
@@ -79,25 +79,32 @@ const future = {
79
79
  },
80
80
  } as unknown as PublicPost;
81
81
 
82
+ // Records the scope the component forwards so the window-threading test can
83
+ // assert the native side hands the active tab's window to the shared hook.
84
+ const hookScope: Record<string, unknown> = {};
85
+
82
86
  jest.mock('@openpeepshq/react', () => ({
83
- useEventsCalendar: () => ({
84
- cells: [
85
- { key: '2026-11-18', inMonth: true },
86
- { key: '2026-11-19', inMonth: true },
87
- ],
88
- byDay: new Map([['2026-11-19', [future]]]),
89
- todayKey: '2026-11-18',
90
- selected: '2026-11-19',
91
- selectedEvents: [future],
92
- selectedLabel: 'Selected day',
93
- setSelectedKey: () => undefined,
94
- monthLabel: 'Parity month',
95
- weekdayLabels: ['S', 'M'],
96
- isLoading: false,
97
- isFetchingNextPage: false,
98
- shiftMonth: () => undefined,
99
- goToday: () => undefined,
100
- }),
87
+ useEventsCalendar: (scope: Record<string, unknown>) => {
88
+ hookScope.window = scope.window;
89
+ return {
90
+ cells: [
91
+ { key: '2026-11-18', inMonth: true },
92
+ { key: '2026-11-19', inMonth: true },
93
+ ],
94
+ byDay: new Map([['2026-11-19', [future]]]),
95
+ todayKey: '2026-11-18',
96
+ selected: '2026-11-19',
97
+ selectedEvents: [future],
98
+ selectedLabel: 'Selected day',
99
+ setSelectedKey: () => undefined,
100
+ monthLabel: 'Parity month',
101
+ weekdayLabels: ['S', 'M'],
102
+ isLoading: false,
103
+ isFetchingNextPage: false,
104
+ shiftMonth: () => undefined,
105
+ goToday: () => undefined,
106
+ };
107
+ },
101
108
  calendarDayNumber: (key: string) => key,
102
109
  calendarEventName: (post: PublicPost) =>
103
110
  post.data.type === 'event' ? (post.data.name ?? '') : '',
@@ -141,4 +148,12 @@ describe('EventsCalendar (native) shared-hook parity', () => {
141
148
  // into the grid or the day list.
142
149
  expect(text).not.toContain('past-event');
143
150
  });
151
+
152
+ it('forwards the active tab window to the shared hook (issue #2131)', async () => {
153
+ // The native component must pass the tab's agenda window into the shared
154
+ // hook so the Upcoming tab never renders past occurrences on the grid —
155
+ // the guard itself lives in @openpeepshq/react, not here.
156
+ await renderCalendar({ window: 'upcoming' });
157
+ expect(hookScope.window).toBe('upcoming');
158
+ });
144
159
  });