@openpeepshq/rn-components 0.24.0 → 0.28.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.
- package/package.json +2 -2
- package/src/components/conversations/ConversationPreviewCard.test.tsx +345 -0
- package/src/components/conversations/ConversationPreviewCard.tsx +29 -24
- package/src/components/custom/navigation/side-menu.test.tsx +9 -0
- package/src/components/custom/navigation/side-menu.tsx +19 -3
- package/src/components/groups/GroupAvatar.test.tsx +20 -2
- package/src/components/groups/GroupAvatar.tsx +7 -1
- package/src/components/jams/JamCallParticipant.test.tsx +303 -0
- package/src/components/jams/JamCallParticipant.tsx +7 -1
- package/src/components/jams/useLateTrackMediaStream.test.ts +139 -25
- package/src/components/jams/useLateTrackMediaStream.ts +62 -19
- package/src/components/post/pieces/ShareMenu.test.tsx +105 -11
- package/src/components/post/pieces/ShareMenu.tsx +55 -10
- package/src/components/post/pieces/modals/SendToConversationModal.tsx +140 -0
- package/src/components/post/pieces/modals/ShareIntoGroupModal.tsx +121 -0
- package/src/components/post/pieces/modals/index.ts +2 -0
- package/src/components/post/pieces/sharePickers.test.tsx +819 -0
- package/src/components/profile/Avatar.test.tsx +19 -0
- package/src/components/profile/Avatar.tsx +9 -1
- package/src/lib/push-notifications.test.ts +244 -0
- package/src/lib/push-notifications.ts +65 -0
- package/src/pages/auth/Login.tsx +16 -2
- package/src/pages/conversations/Index.test.tsx +235 -0
- package/src/pages/conversations/Index.tsx +15 -16
- package/src/pages/settings/Account.test.tsx +4 -0
- package/src/pages/settings/Account.tsx +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"class-variance-authority": "^0.7.1",
|
|
98
98
|
"clsx": "^2.1.1",
|
|
99
99
|
"date-fns": "^4.1.0",
|
|
100
|
-
"i18next": "^
|
|
100
|
+
"i18next": "^26.3.4",
|
|
101
101
|
"i18next-http-backend": "^4.0.10",
|
|
102
102
|
"js-base64": "^3.7.7",
|
|
103
103
|
"livekit-client": "2.19.2",
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout containment for ConversationPreviewCard: the preview row must keep
|
|
3
|
+
* long messages and links inside the screen width. RN flex children don't
|
|
4
|
+
* shrink by default, so the row gets `overflow-hidden` containment, the
|
|
5
|
+
* author label gets `shrink-0`, and the message wrapper gets `flex-1
|
|
6
|
+
* min-w-0 overflow-hidden` — otherwise the markdown view sizes to its
|
|
7
|
+
* intrinsic content width and bleeds past the right screen edge.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const React = require('react');
|
|
11
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
12
|
+
|
|
13
|
+
jest.mock('react-native', () => ({
|
|
14
|
+
View: React.forwardRef(
|
|
15
|
+
(
|
|
16
|
+
props: { testID?: string; className?: string; children?: unknown },
|
|
17
|
+
ref: unknown
|
|
18
|
+
) => {
|
|
19
|
+
void ref;
|
|
20
|
+
return React.createElement(
|
|
21
|
+
'View',
|
|
22
|
+
{ testID: props.testID, className: props.className },
|
|
23
|
+
props.children
|
|
24
|
+
);
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
// react-test-renderer needs a displayName to render forwardRef mocks.
|
|
28
|
+
displayName: 'View',
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
TouchableOpacity: React.forwardRef(
|
|
32
|
+
(
|
|
33
|
+
props: { testID?: string; className?: string; children?: unknown },
|
|
34
|
+
ref: unknown
|
|
35
|
+
) => {
|
|
36
|
+
void ref;
|
|
37
|
+
return React.createElement(
|
|
38
|
+
'TouchableOpacity',
|
|
39
|
+
{ testID: props.testID, className: props.className },
|
|
40
|
+
props.children
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
{ displayName: 'TouchableOpacity' }
|
|
44
|
+
),
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
jest.mock('react-i18next', () => ({
|
|
48
|
+
useTranslation: () => ({
|
|
49
|
+
t: (key: string, opts?: Record<string, string>) => {
|
|
50
|
+
switch (key) {
|
|
51
|
+
case 'conversations.titleWithYou':
|
|
52
|
+
return `${opts?.names ?? ''} and You`;
|
|
53
|
+
case 'common.you':
|
|
54
|
+
return 'You';
|
|
55
|
+
case 'conversations.messageInThread.left':
|
|
56
|
+
return `${opts?.name ?? ''} left`;
|
|
57
|
+
default:
|
|
58
|
+
return key;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
jest.mock('@openpeepshq/common', () => ({
|
|
65
|
+
// The jest config maps the `common` root to contentLength.ts only, so these
|
|
66
|
+
// helpers resolve to the stubs, not the built ESM. They must mirror
|
|
67
|
+
// production semantics — if postHelpers.ts changes, update this stub too
|
|
68
|
+
// (stub drift already bit #2109; the real implementation is pinned by
|
|
69
|
+
// platform/common/src/lib/__tests__/postHelpers.test.ts).
|
|
70
|
+
formatBadgeCount: (n: number) => (n >= 99 ? '99+' : String(n)),
|
|
71
|
+
isConversationLeavePost: (post: {
|
|
72
|
+
inReplyToId?: string | null;
|
|
73
|
+
audience?: { id: string }[] | null;
|
|
74
|
+
profile: { id: string };
|
|
75
|
+
}): boolean => {
|
|
76
|
+
const authorId = post.profile?.id;
|
|
77
|
+
if (!post.inReplyToId || !authorId) return false;
|
|
78
|
+
return !post.audience?.some((p) => p.id === authorId);
|
|
79
|
+
},
|
|
80
|
+
profileName: (profile?: { displayName?: string; handle?: string }) =>
|
|
81
|
+
profile?.displayName || profile?.handle,
|
|
82
|
+
truncateText: (text: string, max: number) =>
|
|
83
|
+
text.length > max ? `${text.slice(0, max - 1)}…` : text,
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
jest.mock('@openpeepshq/react', () => {
|
|
87
|
+
// Load the *real* `conversationTitle` so the card runs against the single
|
|
88
|
+
// shared implementation instead of a mirror that can drift (its full
|
|
89
|
+
// semantics are unit-tested against the real code in platform/react). It is
|
|
90
|
+
// exported from the package root barrel; the
|
|
91
|
+
// `@openpeepshq/react/conversationTitle` subpath below is mapped in
|
|
92
|
+
// jest.config.cjs to the same self-contained module, so this require stays
|
|
93
|
+
// package-anchored (not a relative climb that breaks if the file moves) and
|
|
94
|
+
// pulls in no runtime deps — the module's only import is the type-only
|
|
95
|
+
// `@openpeepshq/common/types`, elided by ts-jest. The card calls it with
|
|
96
|
+
// `{ withYou: true }`, matching the current 4-arg signature
|
|
97
|
+
// `(conversation, t, meId, { fallbackToRoot?, withYou? })`.
|
|
98
|
+
const { conversationTitle } = require('@openpeepshq/react/conversationTitle');
|
|
99
|
+
return {
|
|
100
|
+
conversationTitle,
|
|
101
|
+
useOpenpeeps: () => ({ currentProfile: { id: 'me' } }),
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
jest.mock('@gorhom/bottom-sheet', () => ({
|
|
106
|
+
BottomSheetModal: React.forwardRef(
|
|
107
|
+
(_props: { testID?: string }, ref: unknown) => {
|
|
108
|
+
void ref;
|
|
109
|
+
return React.createElement('BottomSheetModal');
|
|
110
|
+
},
|
|
111
|
+
{ displayName: 'BottomSheetModal' }
|
|
112
|
+
),
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
jest.mock('../ui/dropdown-menu', () => ({
|
|
116
|
+
DropdownMenu: ({ children }: { children?: unknown }) =>
|
|
117
|
+
React.createElement('DropdownMenu', null, children),
|
|
118
|
+
DropdownMenuContent: () => null,
|
|
119
|
+
DropdownMenuItem: () => null,
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
jest.mock('../ui/text', () => ({
|
|
123
|
+
Text: (props: {
|
|
124
|
+
testID?: string;
|
|
125
|
+
className?: string;
|
|
126
|
+
numberOfLines?: number;
|
|
127
|
+
children?: unknown;
|
|
128
|
+
}) =>
|
|
129
|
+
React.createElement(
|
|
130
|
+
'Text',
|
|
131
|
+
{
|
|
132
|
+
testID: props.testID,
|
|
133
|
+
className: props.className,
|
|
134
|
+
numberOfLines: props.numberOfLines,
|
|
135
|
+
},
|
|
136
|
+
props.children
|
|
137
|
+
),
|
|
138
|
+
}));
|
|
139
|
+
|
|
140
|
+
jest.mock('../markdown/OpenpeepsMarkdown', () => ({
|
|
141
|
+
OpenpeepsMarkdown: ({ source }: { source?: string }) =>
|
|
142
|
+
React.createElement('OpenpeepsMarkdown', { testID: 'markdown' }, source),
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
// The shared UnreadBadge (added by main) imports `cn` from `../../lib/utils`
|
|
146
|
+
// (chain → `react-native-config`) and `ThemedText` from `./themed-text`
|
|
147
|
+
// (chain → `@rn-primitives/slot`); both are ESM Jest cannot transform under
|
|
148
|
+
// the CommonJS runtime. Stub it as a props-forwarding element (like the other
|
|
149
|
+
// mocks in this file) instead of a null render: a test below pins that the
|
|
150
|
+
// `unreadCount > 0` branch hands the real component the exact props, so the
|
|
151
|
+
// stub must carry its props into the tree. The badge is a composite node, not
|
|
152
|
+
// a `View`, so the layout assertions (the only `shrink-0` View is the author
|
|
153
|
+
// label) are unaffected.
|
|
154
|
+
jest.mock('../ui/unread-badge', () => ({
|
|
155
|
+
UnreadBadge: (props: { count: number; className?: string }) =>
|
|
156
|
+
React.createElement('UnreadBadge', props),
|
|
157
|
+
}));
|
|
158
|
+
|
|
159
|
+
jest.mock('../custom/date/updating-date', () => ({
|
|
160
|
+
UpdatingDate: () => null,
|
|
161
|
+
}));
|
|
162
|
+
|
|
163
|
+
jest.mock('../profile/Avatar', () => ({
|
|
164
|
+
ProfileAvatar: () => null,
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
jest.mock('./ConversationParticipantsModal', () => ({
|
|
168
|
+
ConversationParticipantsModal: () => null,
|
|
169
|
+
}));
|
|
170
|
+
|
|
171
|
+
jest.mock('../icons/index', () => ({
|
|
172
|
+
BellOffIcon: () => null,
|
|
173
|
+
FlagIcon: () => null,
|
|
174
|
+
Trash2Icon: () => null,
|
|
175
|
+
CalendarIcon: () =>
|
|
176
|
+
React.createElement('CalendarIcon', { testID: 'calendar-icon' }),
|
|
177
|
+
}));
|
|
178
|
+
|
|
179
|
+
import type { PublicPost } from '@openpeepshq/common/types';
|
|
180
|
+
import { ConversationPreviewCard } from './ConversationPreviewCard';
|
|
181
|
+
|
|
182
|
+
const me = { id: 'me', displayName: 'Me', handle: 'me' };
|
|
183
|
+
const bob = { id: 'bob', displayName: 'Bob', handle: 'bob' };
|
|
184
|
+
|
|
185
|
+
const makePost = (over: Partial<PublicPost> = {}): PublicPost =>
|
|
186
|
+
({
|
|
187
|
+
id: 'post-1',
|
|
188
|
+
profile: bob,
|
|
189
|
+
audience: [me, bob],
|
|
190
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
191
|
+
data: { type: 'note', content: 'hello' },
|
|
192
|
+
...over,
|
|
193
|
+
}) as never;
|
|
194
|
+
|
|
195
|
+
const render = (element: React.ReactElement) => {
|
|
196
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
197
|
+
ReactTestRenderer.act(() => {
|
|
198
|
+
tree = ReactTestRenderer.create(element);
|
|
199
|
+
});
|
|
200
|
+
return tree;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const findViews = (
|
|
204
|
+
tree: ReactTestRenderer.ReactTestRenderer,
|
|
205
|
+
predicate: (className: string) => boolean
|
|
206
|
+
) =>
|
|
207
|
+
tree.root.findAll(
|
|
208
|
+
(node) =>
|
|
209
|
+
// Host elements only — each mocked View also shows up once as a
|
|
210
|
+
// composite instance, which would double every count.
|
|
211
|
+
node.type === 'View' &&
|
|
212
|
+
typeof node.props.className === 'string' &&
|
|
213
|
+
predicate(node.props.className)
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
const messageWrapper = (tree: ReactTestRenderer.ReactTestRenderer) => {
|
|
217
|
+
const wrappers = findViews(
|
|
218
|
+
tree,
|
|
219
|
+
(c) =>
|
|
220
|
+
c.includes('flex-1') &&
|
|
221
|
+
c.includes('min-w-0') &&
|
|
222
|
+
c.includes('overflow-hidden')
|
|
223
|
+
);
|
|
224
|
+
expect(wrappers).toHaveLength(1);
|
|
225
|
+
return wrappers[0];
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
test('constrains the message area so previews cannot bleed past the row width', () => {
|
|
229
|
+
const tree = render(
|
|
230
|
+
<ConversationPreviewCard conversation={[makePost()]} onPress={() => {}} />
|
|
231
|
+
);
|
|
232
|
+
const json = JSON.stringify(tree.toJSON());
|
|
233
|
+
|
|
234
|
+
// The preview row is clipped at the card boundary, mirroring the web
|
|
235
|
+
// ChatPreview's overflow-hidden row.
|
|
236
|
+
const rows = findViews(
|
|
237
|
+
tree,
|
|
238
|
+
(c) => c.includes('items-start gap-x-2') && c.includes('overflow-hidden')
|
|
239
|
+
);
|
|
240
|
+
expect(rows).toHaveLength(1);
|
|
241
|
+
|
|
242
|
+
// The message wrapper must carry all three containment classes together:
|
|
243
|
+
// flex-1 (fill the remaining row width), min-w-0 (RN flex children don't
|
|
244
|
+
// shrink by default) and overflow-hidden (clip inside the card).
|
|
245
|
+
messageWrapper(tree);
|
|
246
|
+
|
|
247
|
+
// The author label keeps its intrinsic width so the wrapper gets the rest.
|
|
248
|
+
const labels = findViews(tree, (c) => c.includes('shrink-0'));
|
|
249
|
+
expect(labels).toHaveLength(1);
|
|
250
|
+
|
|
251
|
+
// The markdown preview renders inside the constrained wrapper.
|
|
252
|
+
expect(json).toContain('markdown');
|
|
253
|
+
tree.unmount();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test('truncates the title to a single line deterministically', () => {
|
|
257
|
+
const tree = render(
|
|
258
|
+
<ConversationPreviewCard conversation={[makePost()]} onPress={() => {}} />
|
|
259
|
+
);
|
|
260
|
+
const json = JSON.stringify(tree.toJSON());
|
|
261
|
+
expect(json).toContain('"numberOfLines":1');
|
|
262
|
+
tree.unmount();
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test('passes count and shrink-0 to UnreadBadge when unreadCount > 0', () => {
|
|
266
|
+
const tree = render(
|
|
267
|
+
<ConversationPreviewCard
|
|
268
|
+
conversation={[makePost()]}
|
|
269
|
+
onPress={() => {}}
|
|
270
|
+
unreadCount={5}
|
|
271
|
+
/>
|
|
272
|
+
);
|
|
273
|
+
const badges = tree.root.findAll(
|
|
274
|
+
(node) =>
|
|
275
|
+
// The mocked UnreadBadge renders as a composite host element carrying
|
|
276
|
+
// the exact props the branch passes.
|
|
277
|
+
node.type === 'UnreadBadge'
|
|
278
|
+
);
|
|
279
|
+
expect(badges).toHaveLength(1);
|
|
280
|
+
expect(badges[0].props).toMatchObject({
|
|
281
|
+
count: 5,
|
|
282
|
+
className: 'shrink-0',
|
|
283
|
+
});
|
|
284
|
+
// The badge is not a `View` node, so the author label remains the only
|
|
285
|
+
// `shrink-0` View in the row.
|
|
286
|
+
expect(findViews(tree, (c) => c.includes('shrink-0'))).toHaveLength(1);
|
|
287
|
+
tree.unmount();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// Structural parity only, not a user-content containment pin: the event
|
|
291
|
+
// branch renders a short, locally-scoped `data.name` in native `Text`
|
|
292
|
+
// (which hard-wraps) and never renders markdown or arbitrary user content,
|
|
293
|
+
// so the issue's bleed repro (a long markdown message) does not exercise it.
|
|
294
|
+
// We assert the event wrapper still carries the same `flex-1 min-w-0
|
|
295
|
+
// overflow-hidden` classes as the markdown wrapper so the two lanes stay
|
|
296
|
+
// structurally aligned — a regression that dropped those classes is caught.
|
|
297
|
+
test('keeps the event-name wrapper structurally aligned with the markdown wrapper', () => {
|
|
298
|
+
const tree = render(
|
|
299
|
+
<ConversationPreviewCard
|
|
300
|
+
conversation={[
|
|
301
|
+
makePost({
|
|
302
|
+
id: 'event-post',
|
|
303
|
+
data: {
|
|
304
|
+
type: 'event',
|
|
305
|
+
name: 'A very long event name that should stay inside the card',
|
|
306
|
+
},
|
|
307
|
+
}),
|
|
308
|
+
]}
|
|
309
|
+
onPress={() => {}}
|
|
310
|
+
/>
|
|
311
|
+
);
|
|
312
|
+
const json = JSON.stringify(tree.toJSON());
|
|
313
|
+
// The event wrapper carries the same containment classes as the markdown
|
|
314
|
+
// wrapper (structural parity — the event branch holds no user content).
|
|
315
|
+
messageWrapper(tree);
|
|
316
|
+
expect(json).toContain('A very long event name');
|
|
317
|
+
expect(json).toContain('calendar-icon');
|
|
318
|
+
tree.unmount();
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// Pins behavior, not styles: it passes on both the pre-fix and the fixed
|
|
322
|
+
// component (the leave lane was never the bleed path). The containment tests
|
|
323
|
+
// above are the style pins — mutation checks should expect this one to keep
|
|
324
|
+
// passing on the old head and not misclassify it as an unguarded lane.
|
|
325
|
+
test('leaves a leave post with the "left" label, no message wrapper', () => {
|
|
326
|
+
const tree = render(
|
|
327
|
+
<ConversationPreviewCard
|
|
328
|
+
conversation={[
|
|
329
|
+
makePost({
|
|
330
|
+
id: 'leave-post',
|
|
331
|
+
inReplyToId: 'prev-1',
|
|
332
|
+
audience: [me],
|
|
333
|
+
data: { type: 'note', content: 'should not render' },
|
|
334
|
+
}),
|
|
335
|
+
]}
|
|
336
|
+
onPress={() => {}}
|
|
337
|
+
/>
|
|
338
|
+
);
|
|
339
|
+
const json = JSON.stringify(tree.toJSON());
|
|
340
|
+
expect(json).toContain('Bob left');
|
|
341
|
+
// The leave post's message content is never rendered.
|
|
342
|
+
expect(json).not.toContain('should not render');
|
|
343
|
+
expect(json).not.toContain('markdown');
|
|
344
|
+
tree.unmount();
|
|
345
|
+
});
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
Trash2Icon,
|
|
23
23
|
CalendarIcon,
|
|
24
24
|
} from '../icons/index';
|
|
25
|
-
import { useOpenpeeps } from '@openpeepshq/react';
|
|
25
|
+
import { conversationTitle, useOpenpeeps } from '@openpeepshq/react';
|
|
26
26
|
import { ProfileAvatar } from '../profile/Avatar';
|
|
27
27
|
import { ConversationParticipantsModal } from './ConversationParticipantsModal';
|
|
28
28
|
import { useTranslation } from 'react-i18next';
|
|
@@ -51,19 +51,12 @@ export const ConversationPreviewCard = ({
|
|
|
51
51
|
// audience; show an "X left" preview instead of an empty message.
|
|
52
52
|
const isLeave = lastMessage ? isConversationLeavePost(lastMessage) : false;
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.join(', ');
|
|
61
|
-
const title = otherNames
|
|
62
|
-
? t('conversations.titleWithYou', {
|
|
63
|
-
defaultValue: '{{names}} and You',
|
|
64
|
-
names: otherNames,
|
|
65
|
-
})
|
|
66
|
-
: t('common.you', { defaultValue: 'You' });
|
|
54
|
+
// Shared helper: keeps the leaver/"You" semantics a single implementation
|
|
55
|
+
// with the web inbox and the share pickers; `withYou` renders the inbox
|
|
56
|
+
// form ("{{names}} and You").
|
|
57
|
+
const title = conversationTitle(conversation ?? [], t, currentProfile?.id, {
|
|
58
|
+
withYou: true,
|
|
59
|
+
});
|
|
67
60
|
|
|
68
61
|
const handleDeleteGroupModalPress = useCallback(() => {
|
|
69
62
|
deleteMessageModalRef.current?.present();
|
|
@@ -88,7 +81,7 @@ export const ConversationPreviewCard = ({
|
|
|
88
81
|
))}
|
|
89
82
|
</View>
|
|
90
83
|
<View className="flex min-w-0 flex-1 flex-row items-center gap-2">
|
|
91
|
-
<Text className="truncate font-bold">
|
|
84
|
+
<Text className="truncate font-bold" numberOfLines={1}>
|
|
92
85
|
{truncateText(title, 20)}
|
|
93
86
|
</Text>
|
|
94
87
|
{unreadCount > 0 ? (
|
|
@@ -102,7 +95,7 @@ export const ConversationPreviewCard = ({
|
|
|
102
95
|
className="text-muted-foreground"
|
|
103
96
|
/>
|
|
104
97
|
|
|
105
|
-
<View className="mt-2 flex flex-row items-start gap-x-2">
|
|
98
|
+
<View className="mt-2 flex flex-row items-start gap-x-2 overflow-hidden">
|
|
106
99
|
{isLeave ? (
|
|
107
100
|
<Text className="text-muted-foreground">
|
|
108
101
|
{t('conversations.messageInThread.left', {
|
|
@@ -111,7 +104,9 @@ export const ConversationPreviewCard = ({
|
|
|
111
104
|
</Text>
|
|
112
105
|
) : (
|
|
113
106
|
<>
|
|
114
|
-
|
|
107
|
+
{/* RN flex children default to flexShrink: 0 — pin the author
|
|
108
|
+
label so the message area (flex-1 min-w-0) gets the slack. */}
|
|
109
|
+
<View className="flex flex-row shrink-0 items-center">
|
|
115
110
|
<Text>~</Text>
|
|
116
111
|
{currentProfile?.id === lastMessage.profile.id ? (
|
|
117
112
|
<Text className="ml-1">
|
|
@@ -125,15 +120,24 @@ export const ConversationPreviewCard = ({
|
|
|
125
120
|
<Text className="mx-1">:</Text>
|
|
126
121
|
</View>
|
|
127
122
|
{lastMessage.data?.type === 'event' ? (
|
|
128
|
-
<View className="
|
|
129
|
-
<
|
|
130
|
-
|
|
123
|
+
<View className="min-w-0 flex-1 overflow-hidden">
|
|
124
|
+
<View className="flex flex-row items-center gap-1">
|
|
125
|
+
<CalendarIcon
|
|
126
|
+
size={16}
|
|
127
|
+
className="text-muted-foreground"
|
|
128
|
+
/>
|
|
129
|
+
<Text>
|
|
130
|
+
{(lastMessage.data as { name?: string }).name}
|
|
131
|
+
</Text>
|
|
132
|
+
</View>
|
|
131
133
|
</View>
|
|
132
134
|
) : (
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
<View className="min-w-0 flex-1 overflow-hidden">
|
|
136
|
+
<OpenpeepsMarkdown
|
|
137
|
+
source={lastMessage.data?.content || ''}
|
|
138
|
+
linkPreviewMode="none"
|
|
139
|
+
/>
|
|
140
|
+
</View>
|
|
137
141
|
)}
|
|
138
142
|
</>
|
|
139
143
|
)}
|
|
@@ -141,6 +145,7 @@ export const ConversationPreviewCard = ({
|
|
|
141
145
|
</View>
|
|
142
146
|
</TouchableOpacity>
|
|
143
147
|
<DropdownMenuContent>
|
|
148
|
+
{/* Mute/Report are pre-existing console.log placeholders — no tracking issue exists yet; when one is filed, reference it here (e.g. "see #XXXX") */}
|
|
144
149
|
<DropdownMenuItem onPress={() => console.log('Mute conversation')}>
|
|
145
150
|
<BellOffIcon size={18} className=" mr-2 text-foreground" />
|
|
146
151
|
<Text>Mute conversation</Text>
|
|
@@ -41,6 +41,15 @@ jest.mock('@openpeepshq/common', () => ({
|
|
|
41
41
|
.formatBadgeCount,
|
|
42
42
|
}));
|
|
43
43
|
|
|
44
|
+
jest.mock('react-native-toast-message', () => ({
|
|
45
|
+
__esModule: true,
|
|
46
|
+
default: { show: jest.fn() },
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
jest.mock('../../../lib/push-notifications', () => ({
|
|
50
|
+
unregisterPushForLogout: jest.fn(async () => 'ok'),
|
|
51
|
+
}));
|
|
52
|
+
|
|
44
53
|
// Mutable so each case can drive the unseen-counts hook; the mock factory
|
|
45
54
|
// reads it lazily per call.
|
|
46
55
|
let mockUnseenData: {
|
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
ScrollView,
|
|
7
7
|
useColorScheme,
|
|
8
8
|
} from 'react-native';
|
|
9
|
+
import Toast from 'react-native-toast-message';
|
|
9
10
|
import { Separator } from '../../ui/separator';
|
|
10
11
|
import { TouchableOpacity, View } from 'react-native';
|
|
11
12
|
import { Button } from '../../ui/button';
|
|
12
13
|
import { SvgImage } from '../../ui/svg-image';
|
|
14
|
+
import { unregisterPushForLogout } from '../../../lib/push-notifications';
|
|
13
15
|
import {
|
|
14
16
|
BellIcon,
|
|
15
17
|
BookCheckIcon,
|
|
@@ -116,7 +118,7 @@ export const SideMenu = ({
|
|
|
116
118
|
close,
|
|
117
119
|
onProfilePress,
|
|
118
120
|
}: SideMenuProps) => {
|
|
119
|
-
const { openpeepsApi, currentProfile } = useOpenpeeps();
|
|
121
|
+
const { openpeepsApi, currentProfile, client } = useOpenpeeps();
|
|
120
122
|
const { isMediumScreenOrLarger } = useWindowSize();
|
|
121
123
|
const logout = openpeepsApi.logoutAction();
|
|
122
124
|
const { data: serverInfo } = openpeepsApi.useServerInfo();
|
|
@@ -249,8 +251,22 @@ export const SideMenu = ({
|
|
|
249
251
|
accessibilityLabel={t('navigation.logOut')}
|
|
250
252
|
tooltip={t('navigation.tooltips.logOut')}
|
|
251
253
|
onPress={() => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
+
// The RN side owns FCM cleanup, so this outcome — not the web
|
|
255
|
+
// pushCleanup flag — is what the logout toast reflects.
|
|
256
|
+
void unregisterPushForLogout(client).then((pushResult) => {
|
|
257
|
+
void logout().then(() => {
|
|
258
|
+
if (pushResult === 'failed') {
|
|
259
|
+
Toast.show({
|
|
260
|
+
type: 'error',
|
|
261
|
+
text1: t('settings.notifications.pushCleanupFailed', {
|
|
262
|
+
defaultValue:
|
|
263
|
+
'Could not remove push notifications for this device.',
|
|
264
|
+
}),
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
close?.();
|
|
269
|
+
});
|
|
254
270
|
}}
|
|
255
271
|
>
|
|
256
272
|
<LogOutIcon size={20} className="mr-5 text-destructive" />
|
|
@@ -113,11 +113,15 @@ const findTile = (tree: ReturnType<typeof ReactTestRenderer.create>) =>
|
|
|
113
113
|
);
|
|
114
114
|
|
|
115
115
|
// The tile's single child is the initials Text (not an array).
|
|
116
|
-
const
|
|
116
|
+
const tileText = (tree: ReturnType<typeof ReactTestRenderer.create>) => {
|
|
117
117
|
const child = findTile(tree)?.props?.children;
|
|
118
|
-
return (Array.isArray(child) ? child[0] : child)?.props
|
|
118
|
+
return (Array.isArray(child) ? child[0] : child)?.props;
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
+
const tileFontSize = (
|
|
122
|
+
tree: ReturnType<typeof ReactTestRenderer.create>
|
|
123
|
+
): number | undefined => tileText(tree)?.style?.fontSize;
|
|
124
|
+
|
|
121
125
|
describe('GroupAvatar loading-gap fix (issue #1666 round-4 review item 2)', () => {
|
|
122
126
|
it('renders the initials tile behind the image while the group avatar is still loading', () => {
|
|
123
127
|
const tree = renderGroupAvatar({
|
|
@@ -163,4 +167,18 @@ describe('GroupAvatar loading-gap fix (issue #1666 round-4 review item 2)', () =
|
|
|
163
167
|
expect(tileFontSize(renderGroupAvatar(baseGroup, 'w-12 h-12'))).toBe(18);
|
|
164
168
|
expect(tileFontSize(renderGroupAvatar(baseGroup, 'size-14'))).toBe(21);
|
|
165
169
|
});
|
|
170
|
+
|
|
171
|
+
it('centers the initials glyph deterministically: lineHeight = fontSize and no font padding (issue #1666 QA 2026-11-24)', () => {
|
|
172
|
+
// The QA report: initials/fallback avatars sit low in the selection chips
|
|
173
|
+
// while image avatars align. The image is a true square disc; the initials
|
|
174
|
+
// must be the same. Without an explicit lineHeight the text box is the
|
|
175
|
+
// platform font line-height (taller than the glyphs) plus font-metric
|
|
176
|
+
// padding, so items-center centers the *box* below the *glyph*. lineHeight
|
|
177
|
+
// = fontSize + includeFontPadding: false make the box exactly glyph height
|
|
178
|
+
// — pin both so a revert fails.
|
|
179
|
+
const tree = renderGroupAvatar(baseGroup);
|
|
180
|
+
const text = tileText(tree);
|
|
181
|
+
expect(text.style.lineHeight).toBe(text.style.fontSize);
|
|
182
|
+
expect(text.style.includeFontPadding).toBe(false);
|
|
183
|
+
});
|
|
166
184
|
});
|
|
@@ -62,7 +62,13 @@ export const GroupAvatar = ({
|
|
|
62
62
|
)}
|
|
63
63
|
style={{ backgroundColor }}
|
|
64
64
|
>
|
|
65
|
-
|
|
65
|
+
{/* lineHeight = fontSize + no font padding make the text box exactly the
|
|
66
|
+
glyph height, so items-center centers the initials on the circle
|
|
67
|
+
(issue #1666 QA: initials avatars sit low while image avatars align). */}
|
|
68
|
+
<Text
|
|
69
|
+
className="text-foreground font-medium"
|
|
70
|
+
style={{ fontSize, lineHeight: fontSize, includeFontPadding: false }}
|
|
71
|
+
>
|
|
66
72
|
{getInitials(group?.displayName, group?.handle)}
|
|
67
73
|
</Text>
|
|
68
74
|
</View>
|