@openpeepshq/rn-components 0.20.0 → 0.22.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 +3 -4
- package/src/components/jams/JamCallParticipant.tsx +84 -16
- package/src/components/jams/JamChatMessage.test.tsx +139 -0
- package/src/components/jams/JamChatMessage.tsx +13 -0
- package/src/components/jams/JamPeopleDrawer.test.tsx +77 -3
- package/src/components/jams/JamPeopleDrawer.tsx +94 -3
- package/src/components/jams/JamRoom.tsx +15 -0
- package/src/components/markdown/OpenpeepsMarkdown.tsx +10 -3
- package/src/components/markdown/theme.test.ts +78 -0
- package/src/components/markdown/theme.ts +30 -12
- package/src/components/post/CompactReplyParent.test.tsx +337 -0
- package/src/components/post/CompactReplyParent.tsx +21 -5
- package/src/components/post/TruncatedMarkdown.test.tsx +201 -0
- package/src/components/post/TruncatedMarkdown.tsx +98 -10
- package/src/components/preview-link/local/WelcomePreview.tsx +1 -0
- package/src/components/resources/CategoryPathPicker.tsx +8 -2
- package/src/components/resources/ResourceCard.test.tsx +48 -4
- package/src/components/resources/ResourceCard.tsx +8 -2
- package/src/components/resources/ResourceLibrary.test.tsx +40 -2
- package/src/components/resources/ResourceLibrary.tsx +11 -6
- package/src/lib/downloadFile.ts +13 -6
- package/src/lib/moduleResolverRootGuard.test.ts +281 -0
- package/src/pages/settings/Account.test.tsx +303 -0
- package/src/pages/settings/Account.tsx +70 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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",
|
|
@@ -142,9 +142,9 @@
|
|
|
142
142
|
"timezones-list": "^3.1.0",
|
|
143
143
|
"validator": "^13.15.23",
|
|
144
144
|
"zustand": "^5.0.3",
|
|
145
|
-
"@openpeepshq/common": "^0.
|
|
145
|
+
"@openpeepshq/common": "^0.15.0",
|
|
146
146
|
"@openpeepshq/fetch-client": "^0.2.1",
|
|
147
|
-
"@openpeepshq/react": "^0.
|
|
147
|
+
"@openpeepshq/react": "^0.23.0"
|
|
148
148
|
},
|
|
149
149
|
"devDependencies": {
|
|
150
150
|
"@babel/core": "^7.26.7",
|
|
@@ -171,7 +171,6 @@
|
|
|
171
171
|
"@types/validator": "^13.15.10",
|
|
172
172
|
"@typescript-eslint/eslint-plugin": "^8.72.0",
|
|
173
173
|
"@typescript-eslint/parser": "^8.72.0",
|
|
174
|
-
"babel-plugin-module-resolver": "^5.0.2",
|
|
175
174
|
"commitlint": "^17.0.2",
|
|
176
175
|
"del-cli": "^5.1.0",
|
|
177
176
|
"eslint": "^10.14.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useReducer, useRef } from 'react';
|
|
2
|
-
import { Pressable, StyleSheet, View } from 'react-native';
|
|
2
|
+
import { Alert, Pressable, StyleSheet, View } from 'react-native';
|
|
3
3
|
import Sound from 'react-native-sound';
|
|
4
4
|
import {
|
|
5
5
|
isTrackReference,
|
|
@@ -16,10 +16,12 @@ import {
|
|
|
16
16
|
useJamContext,
|
|
17
17
|
useJamEventsContext,
|
|
18
18
|
useJamParticipantMute,
|
|
19
|
+
useJamParticipantRemove,
|
|
19
20
|
useRaisedHands,
|
|
20
21
|
} from '@openpeepshq/react';
|
|
21
22
|
import {
|
|
22
23
|
AudioLinesIcon,
|
|
24
|
+
BanIcon,
|
|
23
25
|
EllipsisIcon,
|
|
24
26
|
HandIcon,
|
|
25
27
|
MicIcon,
|
|
@@ -98,17 +100,16 @@ const JamSpotlightMenuItem = ({
|
|
|
98
100
|
};
|
|
99
101
|
|
|
100
102
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
+
* Moderator-only menu on a remote tile: mute and remove, plus the
|
|
104
|
+
* room-wide spotlight toggle when the caller may spotlight. Mirrors the
|
|
105
|
+
* web `JamParticipantModeratorMenu` — it is mounted only for moderators.
|
|
103
106
|
*/
|
|
104
107
|
const JamParticipantMenu = ({
|
|
105
108
|
trackRef,
|
|
106
|
-
canMute,
|
|
107
109
|
spotlighted,
|
|
108
110
|
onToggleSpotlight,
|
|
109
111
|
}: {
|
|
110
112
|
trackRef: TrackReferenceOrPlaceholder;
|
|
111
|
-
canMute: boolean;
|
|
112
113
|
spotlighted: boolean;
|
|
113
114
|
onToggleSpotlight?: () => void;
|
|
114
115
|
}) => {
|
|
@@ -118,6 +119,11 @@ const JamParticipantMenu = ({
|
|
|
118
119
|
onSuccess: (text1) => Toast.show({ type: 'success', text1 }),
|
|
119
120
|
onError: (text1) => Toast.show({ type: 'error', text1 }),
|
|
120
121
|
});
|
|
122
|
+
const handleRemove = useJamParticipantRemove({
|
|
123
|
+
participant: trackRef.participant,
|
|
124
|
+
onSuccess: (text1) => Toast.show({ type: 'success', text1 }),
|
|
125
|
+
onError: (text1) => Toast.show({ type: 'error', text1 }),
|
|
126
|
+
});
|
|
121
127
|
|
|
122
128
|
return (
|
|
123
129
|
<DropdownMenu>
|
|
@@ -133,15 +139,36 @@ const JamParticipantMenu = ({
|
|
|
133
139
|
</DropdownMenuTrigger>
|
|
134
140
|
<DropdownMenuContent align="start">
|
|
135
141
|
<DropdownMenuGroup>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
<DropdownMenuItem
|
|
143
|
+
className="flex-row items-center gap-x-2"
|
|
144
|
+
onPress={() => void handleMute()}
|
|
145
|
+
>
|
|
146
|
+
<MicOffIcon size={16} className="text-foreground" />
|
|
147
|
+
<ThemedText>{t('jams.participants.muteParticipant')}</ThemedText>
|
|
148
|
+
</DropdownMenuItem>
|
|
149
|
+
<DropdownMenuItem
|
|
150
|
+
className="flex-row items-center gap-x-2"
|
|
151
|
+
onPress={() =>
|
|
152
|
+
Alert.alert(
|
|
153
|
+
t('jams.participantMenu.removeFromJam'),
|
|
154
|
+
t('jams.participants.removeConfirm'),
|
|
155
|
+
[
|
|
156
|
+
{
|
|
157
|
+
text: t('common.actions.cancel'),
|
|
158
|
+
style: 'cancel',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
text: t('jams.participantMenu.removeFromJam'),
|
|
162
|
+
style: 'destructive',
|
|
163
|
+
onPress: () => void handleRemove(),
|
|
164
|
+
},
|
|
165
|
+
]
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
>
|
|
169
|
+
<BanIcon size={16} className="text-destructive" />
|
|
170
|
+
<ThemedText>{t('jams.participantMenu.removeFromJam')}</ThemedText>
|
|
171
|
+
</DropdownMenuItem>
|
|
145
172
|
{onToggleSpotlight ? (
|
|
146
173
|
<JamSpotlightMenuItem
|
|
147
174
|
spotlighted={spotlighted}
|
|
@@ -154,6 +181,43 @@ const JamParticipantMenu = ({
|
|
|
154
181
|
);
|
|
155
182
|
};
|
|
156
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Spotlight-only menu on a remote tile for viewers who may spotlight but
|
|
186
|
+
* are not moderators. Mirrors the web spotlight-only `PopupMenu` so a
|
|
187
|
+
* non-moderator host never sees the moderation container.
|
|
188
|
+
*/
|
|
189
|
+
const JamParticipantSpotlightMenu = ({
|
|
190
|
+
spotlighted,
|
|
191
|
+
onToggleSpotlight,
|
|
192
|
+
}: {
|
|
193
|
+
spotlighted: boolean;
|
|
194
|
+
onToggleSpotlight: () => void;
|
|
195
|
+
}) => {
|
|
196
|
+
const { t } = useTranslation();
|
|
197
|
+
return (
|
|
198
|
+
<DropdownMenu>
|
|
199
|
+
<DropdownMenuTrigger asChild>
|
|
200
|
+
<Button
|
|
201
|
+
size="icon"
|
|
202
|
+
variant="ghost"
|
|
203
|
+
className="size-8 rounded-full bg-card"
|
|
204
|
+
accessibilityLabel={t('jams.speakerView.spotlight')}
|
|
205
|
+
>
|
|
206
|
+
<EllipsisIcon size={16} className="text-foreground" />
|
|
207
|
+
</Button>
|
|
208
|
+
</DropdownMenuTrigger>
|
|
209
|
+
<DropdownMenuContent align="start">
|
|
210
|
+
<DropdownMenuGroup>
|
|
211
|
+
<JamSpotlightMenuItem
|
|
212
|
+
spotlighted={spotlighted}
|
|
213
|
+
onToggleSpotlight={onToggleSpotlight}
|
|
214
|
+
/>
|
|
215
|
+
</DropdownMenuGroup>
|
|
216
|
+
</DropdownMenuContent>
|
|
217
|
+
</DropdownMenu>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
|
|
157
221
|
/** Raised hand + mic state on top, name (with moderator `*` prefix) at the bottom. */
|
|
158
222
|
const JamParticipantOverlay = ({
|
|
159
223
|
trackRef,
|
|
@@ -226,10 +290,14 @@ const JamParticipantOverlay = ({
|
|
|
226
290
|
<HandIcon size={iconSize} className="text-foreground" />
|
|
227
291
|
</View>
|
|
228
292
|
) : null}
|
|
229
|
-
{
|
|
293
|
+
{viewerIsModerator && !participant.isLocal ? (
|
|
230
294
|
<JamParticipantMenu
|
|
231
295
|
trackRef={trackRef}
|
|
232
|
-
|
|
296
|
+
spotlighted={spotlighted}
|
|
297
|
+
onToggleSpotlight={onToggleSpotlight}
|
|
298
|
+
/>
|
|
299
|
+
) : onToggleSpotlight && !participant.isLocal ? (
|
|
300
|
+
<JamParticipantSpotlightMenu
|
|
233
301
|
spotlighted={spotlighted}
|
|
234
302
|
onToggleSpotlight={onToggleSpotlight}
|
|
235
303
|
/>
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RN pin for the dedicated `kicked` chat-message branch (issue #303
|
|
3
|
+
* round-15 suggestion 1, the RN twin of
|
|
4
|
+
* `platform/react/.../JamChatMessage.test.tsx`).
|
|
5
|
+
*
|
|
6
|
+
* `kicked` is part of the attendance-event union in `jamEventDataSchema`, but
|
|
7
|
+
* `JamChatMessage` deliberately keeps it OUT of the `attendance` array so this
|
|
8
|
+
* branch (profile name + `jams.chat.wasRemoved`) runs instead of the generic
|
|
9
|
+
* attendance renderer. A future edit that adds `kicked` to that array — or
|
|
10
|
+
* reorders the branches — would silently degrade the message to the generic
|
|
11
|
+
* "X kicked the jam" output; these render tests pin the dedicated copy so that
|
|
12
|
+
* regression fails here, on both stacks.
|
|
13
|
+
*
|
|
14
|
+
* Only RN, i18n, the openpeeps context and the leaf primitives are stubbed.
|
|
15
|
+
* `ThemedText` is the single text primitive the message renders through, so
|
|
16
|
+
* the mock records the concatenated string content of every ThemedText it
|
|
17
|
+
* renders — the assertions read that ordered log instead of walking the tree.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const React = require('react');
|
|
21
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
22
|
+
|
|
23
|
+
// The string content of every ThemedText render, in document order.
|
|
24
|
+
const mockRenderedTexts: string[] = [];
|
|
25
|
+
let mockProfile:
|
|
26
|
+
| { id: string; displayName: string; handle: string }
|
|
27
|
+
| undefined;
|
|
28
|
+
let mockLoading = false;
|
|
29
|
+
|
|
30
|
+
jest.mock('react-native', () => ({
|
|
31
|
+
View: (props: { children?: unknown }) =>
|
|
32
|
+
React.createElement('View', null, props.children),
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
jest.mock('react-i18next', () => ({
|
|
36
|
+
useTranslation: () => ({
|
|
37
|
+
// Value mirrors `platform/i18n/src/locales/en.json` jams.chat.wasRemoved
|
|
38
|
+
// so the rendered copy pins the key the user actually sees.
|
|
39
|
+
t: (key: string) =>
|
|
40
|
+
key === 'jams.chat.wasRemoved' ? 'was removed from the jam' : key,
|
|
41
|
+
}),
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
45
|
+
useOpenpeeps: () => ({
|
|
46
|
+
openpeepsApi: {
|
|
47
|
+
useProfile: () => ({ data: mockProfile, isLoading: mockLoading }),
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
jest.mock('@openpeepshq/common', () => ({
|
|
53
|
+
// `truncateText` is only used by the message branch, which these cases do
|
|
54
|
+
// not reach; a passthrough keeps the suite parseable.
|
|
55
|
+
truncateText: (text: string | null | undefined) => text ?? '',
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
jest.mock('../custom/date/updating-date', () => ({
|
|
59
|
+
UpdatingDate: () => React.createElement('UpdatingDate'),
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
jest.mock('../markdown/index', () => ({
|
|
63
|
+
OpenpeepsMarkdown: () => null,
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
jest.mock('../ui/themed-text', () => ({
|
|
67
|
+
ThemedText: (props: { children?: unknown }) => {
|
|
68
|
+
const parts: string[] = [];
|
|
69
|
+
const collect = (node: unknown) => {
|
|
70
|
+
if (typeof node === 'string' && node) parts.push(node);
|
|
71
|
+
else if (Array.isArray(node)) for (const p of node) collect(p);
|
|
72
|
+
};
|
|
73
|
+
collect(props.children);
|
|
74
|
+
const text = parts.join('');
|
|
75
|
+
if (text) mockRenderedTexts.push(text);
|
|
76
|
+
return React.createElement('ThemedText', null, props.children);
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
jest.mock('../profile/Avatar', () => ({
|
|
81
|
+
ProfileAvatar: () => React.createElement('ProfileAvatar'),
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
const { JamChatMessage } = require('./JamChatMessage');
|
|
85
|
+
|
|
86
|
+
const baseMessage = {
|
|
87
|
+
id: 'evt-1',
|
|
88
|
+
jamId: 'jam-1',
|
|
89
|
+
profileId: 'kicked-1',
|
|
90
|
+
createdAt: '2026-11-22T20:00:00.000Z',
|
|
91
|
+
updatedAt: '2026-11-22T20:00:00.000Z',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const renderMessage = (message: Record<string, unknown>) => {
|
|
95
|
+
mockRenderedTexts.length = 0;
|
|
96
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
97
|
+
ReactTestRenderer.act(() => {
|
|
98
|
+
tree = ReactTestRenderer.create(
|
|
99
|
+
React.createElement(JamChatMessage, { message })
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
return tree;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
describe('JamChatMessage kicked branch (RN)', () => {
|
|
106
|
+
beforeEach(() => {
|
|
107
|
+
mockProfile = {
|
|
108
|
+
id: 'kicked-1',
|
|
109
|
+
displayName: 'Kicked Person',
|
|
110
|
+
handle: 'kicked',
|
|
111
|
+
};
|
|
112
|
+
mockLoading = false;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('renders the profile name plus the dedicated "was removed" copy', () => {
|
|
116
|
+
renderMessage({ ...baseMessage, type: 'kicked' });
|
|
117
|
+
const rendered = mockRenderedTexts.join('');
|
|
118
|
+
expect(rendered).toContain('Kicked Person');
|
|
119
|
+
expect(rendered).toContain('was removed from the jam');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('does not fall through to the generic attendance rendering for kicked', () => {
|
|
123
|
+
// If `kicked` had been (re)added to the `attendance` array, the generic
|
|
124
|
+
// branch would render the raw type as the label ("… kicked the jam")
|
|
125
|
+
// instead of the dedicated copy — that wrong output must not appear.
|
|
126
|
+
renderMessage({ ...baseMessage, type: 'kicked' });
|
|
127
|
+
expect(mockRenderedTexts.join('')).not.toContain('kicked the jam');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('still routes real attendance events (join) through the generic branch', () => {
|
|
131
|
+
// Guards against the fix overshooting: `join` keeps the generic
|
|
132
|
+
// "X joined the jam" rendering, proving the dedicated branch only
|
|
133
|
+
// special-cases `kicked`.
|
|
134
|
+
renderMessage({ ...baseMessage, type: 'join' });
|
|
135
|
+
const rendered = mockRenderedTexts.join('');
|
|
136
|
+
expect(rendered).toContain('joined');
|
|
137
|
+
expect(rendered).not.toContain('was removed from the jam');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import {
|
|
4
5
|
truncateText,
|
|
5
6
|
type JamEvent,
|
|
@@ -29,6 +30,7 @@ export const JamChatMessage = ({
|
|
|
29
30
|
message,
|
|
30
31
|
mentionProfiles = [],
|
|
31
32
|
}: JamChatMessageProps) => {
|
|
33
|
+
const { t } = useTranslation();
|
|
32
34
|
const { openpeepsApi } = useOpenpeeps();
|
|
33
35
|
const profileQuery = openpeepsApi.useProfile(message.profileId || 'unknown');
|
|
34
36
|
const profile = profileQuery.data;
|
|
@@ -82,5 +84,16 @@ export const JamChatMessage = ({
|
|
|
82
84
|
);
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
if (message.type === 'kicked') {
|
|
88
|
+
return (
|
|
89
|
+
<View className="items-center justify-center">
|
|
90
|
+
<ThemedText className="text-center text-sm text-muted-foreground">
|
|
91
|
+
{name} {t('jams.chat.wasRemoved')}{' '}
|
|
92
|
+
<UpdatingDate date={message.createdAt} />
|
|
93
|
+
</ThemedText>
|
|
94
|
+
</View>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
return null;
|
|
86
99
|
};
|
|
@@ -24,14 +24,21 @@ const mockParticipants: unknown[] = [];
|
|
|
24
24
|
let mockIsModerator = false;
|
|
25
25
|
let mockHasWaitingRoom = false;
|
|
26
26
|
let mockWaitingProfiles: unknown[] = [];
|
|
27
|
+
let mockBannedIds: string[] = [];
|
|
28
|
+
const mockPressHandlers: Array<() => void> = [];
|
|
27
29
|
|
|
28
30
|
jest.mock('react-native', () => ({
|
|
29
31
|
View: (props: { children?: unknown }) =>
|
|
30
32
|
React.createElement('View', null, props.children),
|
|
31
33
|
ScrollView: (props: { children?: unknown }) =>
|
|
32
34
|
React.createElement('ScrollView', null, props.children),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
// Records every press handler in render order so a test can fire the
|
|
36
|
+
// "Removed" header toggle (the only Pressable when the drawer has no
|
|
37
|
+
// participants / waiting room — see the round-15 suggestion-2 case).
|
|
38
|
+
Pressable: (props: { children?: unknown; onPress?: () => void }) => {
|
|
39
|
+
if (props.onPress) mockPressHandlers.push(props.onPress);
|
|
40
|
+
return React.createElement('Pressable', null, props.children);
|
|
41
|
+
},
|
|
35
42
|
Text: (props: { children?: unknown }) =>
|
|
36
43
|
React.createElement('Text', null, props.children),
|
|
37
44
|
}));
|
|
@@ -79,6 +86,20 @@ jest.mock('@openpeepshq/react', () => ({
|
|
|
79
86
|
waitingProfiles: mockWaitingProfiles,
|
|
80
87
|
admittingId: null,
|
|
81
88
|
admit: () => {},
|
|
89
|
+
// Mirror the real hook's banned-sublist contract (the drawer reads
|
|
90
|
+
// bannedIds/liftingId/liftBan when isModerator is true); empty keeps the
|
|
91
|
+
// "Removed" section hidden so these assertions stay on the Observers pin.
|
|
92
|
+
bannedIds: mockBannedIds,
|
|
93
|
+
liftingId: null,
|
|
94
|
+
liftBan: () => {},
|
|
95
|
+
}),
|
|
96
|
+
// The "Removed" sublist row resolves each banned id through
|
|
97
|
+
// `openpeepsApi.useProfile(id).data`; returning `undefined` exercises the
|
|
98
|
+
// unresolved fallback (the full profile id) that round-15 suggestion 2 pins.
|
|
99
|
+
useOpenpeeps: () => ({
|
|
100
|
+
openpeepsApi: {
|
|
101
|
+
useProfile: () => ({ data: undefined }),
|
|
102
|
+
},
|
|
82
103
|
}),
|
|
83
104
|
}));
|
|
84
105
|
|
|
@@ -92,6 +113,8 @@ jest.mock('../icons/index', () => {
|
|
|
92
113
|
React.createElement(name, props);
|
|
93
114
|
return {
|
|
94
115
|
AudioLinesIcon: make('AudioLinesIcon'),
|
|
116
|
+
ChevronDownIcon: make('ChevronDownIcon'),
|
|
117
|
+
ChevronRightIcon: make('ChevronRightIcon'),
|
|
95
118
|
EyeOnIcon: make('EyeOnIcon'),
|
|
96
119
|
HandIcon: make('HandIcon'),
|
|
97
120
|
MicIcon: make('MicIcon'),
|
|
@@ -146,14 +169,28 @@ jest.mock('../ui/themed-text', () => ({
|
|
|
146
169
|
},
|
|
147
170
|
}));
|
|
148
171
|
|
|
172
|
+
// The package ships ESM-only source (see the jest.config.cjs notes); the
|
|
173
|
+
// drawer only calls Toast.show for lift-ban errors, which these cases never
|
|
174
|
+
// reach, so an inert mock keeps the suite parseable.
|
|
175
|
+
jest.mock('react-native-toast-message', () => {
|
|
176
|
+
const Toast = { show: jest.fn() };
|
|
177
|
+
return { __esModule: true, default: Toast };
|
|
178
|
+
});
|
|
179
|
+
|
|
149
180
|
const { JamPeopleDrawer } = require('./JamPeopleDrawer');
|
|
150
181
|
|
|
151
|
-
const renderDrawer = (
|
|
182
|
+
const renderDrawer = (
|
|
183
|
+
sessions: number,
|
|
184
|
+
waitingRoom: boolean = false,
|
|
185
|
+
bannedIds: string[] = []
|
|
186
|
+
) => {
|
|
152
187
|
mockSessions = sessions;
|
|
153
188
|
mockIsModerator = waitingRoom;
|
|
154
189
|
mockHasWaitingRoom = waitingRoom;
|
|
155
190
|
mockWaitingProfiles = waitingRoom ? [{ id: 'w1' }] : [];
|
|
191
|
+
mockBannedIds = bannedIds;
|
|
156
192
|
mockRenderedTexts.length = 0;
|
|
193
|
+
mockPressHandlers.length = 0;
|
|
157
194
|
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
158
195
|
ReactTestRenderer.act(() => {
|
|
159
196
|
tree = ReactTestRenderer.create(
|
|
@@ -214,3 +251,40 @@ describe('JamPeopleDrawer observers section (RN)', () => {
|
|
|
214
251
|
expect(texts).not.toContain('external observer');
|
|
215
252
|
});
|
|
216
253
|
});
|
|
254
|
+
|
|
255
|
+
describe('JamPeopleDrawer "Removed" sublist fallback (RN, issue #303 round-15 suggestion 2)', () => {
|
|
256
|
+
// Independent of the observers renderDrawer: the fallback case needs a
|
|
257
|
+
// moderator with a non-empty banned list but no waiting room / participants,
|
|
258
|
+
// which the observers helper (isModerator === waitingRoom) cannot express.
|
|
259
|
+
const renderBannedDrawer = (bannedIds: string[]) => {
|
|
260
|
+
mockIsModerator = true;
|
|
261
|
+
mockHasWaitingRoom = false;
|
|
262
|
+
mockWaitingProfiles = [];
|
|
263
|
+
mockBannedIds = bannedIds;
|
|
264
|
+
mockRenderedTexts.length = 0;
|
|
265
|
+
mockPressHandlers.length = 0;
|
|
266
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
267
|
+
ReactTestRenderer.act(() => {
|
|
268
|
+
tree = ReactTestRenderer.create(
|
|
269
|
+
React.createElement(JamPeopleDrawer, { open: true, onClose: () => {} })
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
// The section is collapsed by default; fire the header toggle (the only
|
|
273
|
+
// Pressable with an onPress when there are no participants / waiting room)
|
|
274
|
+
// so the rows mount and their name fallbacks render.
|
|
275
|
+
ReactTestRenderer.act(() => {
|
|
276
|
+
mockPressHandlers.forEach((onPress) => onPress());
|
|
277
|
+
});
|
|
278
|
+
return tree;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
it('shows the full profile id for an unresolved row, not a truncated slice', () => {
|
|
282
|
+
// The useProfile mock returns undefined for every id, so the row hits the
|
|
283
|
+
// unresolved fallback. Asserting the FULL id is present catches the old
|
|
284
|
+
// raw-slice behavior (the first 8 chars only) — a 36-char id cannot appear
|
|
285
|
+
// when only 8 chars are rendered.
|
|
286
|
+
renderBannedDrawer(['banned-2x-0000-0000-0000-000000000000']);
|
|
287
|
+
const text = mockRenderedTexts.join(' ');
|
|
288
|
+
expect(text).toContain('banned-2x-0000-0000-0000-000000000000');
|
|
289
|
+
});
|
|
290
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ScrollView, View } from 'react-native';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Pressable, ScrollView, View } from 'react-native';
|
|
3
|
+
import Toast from 'react-native-toast-message';
|
|
3
4
|
import { useParticipants, useRoomContext } from '@livekit/react-native';
|
|
4
5
|
import type { Participant } from 'livekit-client';
|
|
5
6
|
import { useTranslation } from 'react-i18next';
|
|
@@ -9,9 +10,12 @@ import {
|
|
|
9
10
|
parseParticipantMetadata,
|
|
10
11
|
useJamExternalSessions,
|
|
11
12
|
useJamPeople,
|
|
13
|
+
useOpenpeeps,
|
|
12
14
|
} from '@openpeepshq/react';
|
|
13
15
|
import {
|
|
14
16
|
AudioLinesIcon,
|
|
17
|
+
ChevronDownIcon,
|
|
18
|
+
ChevronRightIcon,
|
|
15
19
|
EyeOnIcon,
|
|
16
20
|
HandIcon,
|
|
17
21
|
MicIcon,
|
|
@@ -119,6 +123,7 @@ const JamObserversSection = ({ count }: { count: number }) => {
|
|
|
119
123
|
*/
|
|
120
124
|
export const JamPeopleDrawer = ({ open, onClose }: JamPeopleDrawerProps) => {
|
|
121
125
|
const { t } = useTranslation();
|
|
126
|
+
const [bannedExpanded, setBannedExpanded] = useState(false);
|
|
122
127
|
const room = useRoomContext();
|
|
123
128
|
const participants = useParticipants();
|
|
124
129
|
const externalSessions = useJamExternalSessions();
|
|
@@ -133,7 +138,14 @@ export const JamPeopleDrawer = ({ open, onClose }: JamPeopleDrawerProps) => {
|
|
|
133
138
|
waitingProfiles,
|
|
134
139
|
admittingId,
|
|
135
140
|
admit,
|
|
136
|
-
|
|
141
|
+
bannedIds,
|
|
142
|
+
liftingId,
|
|
143
|
+
liftBan,
|
|
144
|
+
} = useJamPeople({
|
|
145
|
+
room,
|
|
146
|
+
participants,
|
|
147
|
+
onLiftError: (text1) => Toast.show({ type: 'error', text1 }),
|
|
148
|
+
});
|
|
137
149
|
|
|
138
150
|
if (!open) return null;
|
|
139
151
|
|
|
@@ -208,6 +220,45 @@ export const JamPeopleDrawer = ({ open, onClose }: JamPeopleDrawerProps) => {
|
|
|
208
220
|
</View>
|
|
209
221
|
</View>
|
|
210
222
|
) : null}
|
|
223
|
+
|
|
224
|
+
{isModerator && bannedIds.length > 0 ? (
|
|
225
|
+
<View>
|
|
226
|
+
<Pressable
|
|
227
|
+
accessibilityRole="button"
|
|
228
|
+
accessibilityState={{ expanded: bannedExpanded }}
|
|
229
|
+
onPress={() => setBannedExpanded((current) => !current)}
|
|
230
|
+
>
|
|
231
|
+
<View className="flex-row items-center justify-between gap-2">
|
|
232
|
+
<SectionHeading>
|
|
233
|
+
{`${t('jams.people.banned')} (${bannedIds.length})`}
|
|
234
|
+
</SectionHeading>
|
|
235
|
+
{bannedExpanded ? (
|
|
236
|
+
<ChevronDownIcon
|
|
237
|
+
size={16}
|
|
238
|
+
className="text-muted-foreground"
|
|
239
|
+
/>
|
|
240
|
+
) : (
|
|
241
|
+
<ChevronRightIcon
|
|
242
|
+
size={16}
|
|
243
|
+
className="text-muted-foreground"
|
|
244
|
+
/>
|
|
245
|
+
)}
|
|
246
|
+
</View>
|
|
247
|
+
</Pressable>
|
|
248
|
+
{bannedExpanded ? (
|
|
249
|
+
<View className="mt-1 gap-2">
|
|
250
|
+
{bannedIds.map((profileId) => (
|
|
251
|
+
<BannedProfileRow
|
|
252
|
+
key={profileId}
|
|
253
|
+
profileId={profileId}
|
|
254
|
+
lifting={liftingId === profileId}
|
|
255
|
+
onLift={() => liftBan(profileId)}
|
|
256
|
+
/>
|
|
257
|
+
))}
|
|
258
|
+
</View>
|
|
259
|
+
) : null}
|
|
260
|
+
</View>
|
|
261
|
+
) : null}
|
|
211
262
|
</ScrollView>
|
|
212
263
|
</JamDrawer>
|
|
213
264
|
);
|
|
@@ -227,3 +278,43 @@ function WaitingRoomAvatar({ profile }: { profile: JamWaitingProfile }) {
|
|
|
227
278
|
/>
|
|
228
279
|
);
|
|
229
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* A banned-sublist row. Splits into its own component so the per-id
|
|
283
|
+
* `useProfile(id)` only fires when the row is actually mounted — i.e. when the
|
|
284
|
+
* moderator expands the "Removed" sublist — instead of a full profile-directory
|
|
285
|
+
* fetch up front.
|
|
286
|
+
*/
|
|
287
|
+
const BannedProfileRow = ({
|
|
288
|
+
profileId,
|
|
289
|
+
lifting,
|
|
290
|
+
onLift,
|
|
291
|
+
}: {
|
|
292
|
+
profileId: string;
|
|
293
|
+
lifting: boolean;
|
|
294
|
+
onLift: () => void;
|
|
295
|
+
}) => {
|
|
296
|
+
const t = useTranslation().t;
|
|
297
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
298
|
+
const profile = openpeepsApi.useProfile(profileId).data;
|
|
299
|
+
return (
|
|
300
|
+
<View className="flex-row items-center justify-between gap-2">
|
|
301
|
+
<View className="min-w-0 flex-1 flex-row items-center gap-2 opacity-60">
|
|
302
|
+
{profile ? (
|
|
303
|
+
<ProfileAvatar profile={profile} className="size-8" />
|
|
304
|
+
) : null}
|
|
305
|
+
<ThemedText numberOfLines={1} className="shrink text-sm">
|
|
306
|
+
{profile ? profileName(profile) : profileId}
|
|
307
|
+
</ThemedText>
|
|
308
|
+
</View>
|
|
309
|
+
<Button
|
|
310
|
+
variant="outline"
|
|
311
|
+
size="icon"
|
|
312
|
+
onPress={onLift}
|
|
313
|
+
disabled={lifting}
|
|
314
|
+
accessibilityLabel={t('jams.people.unban')}
|
|
315
|
+
>
|
|
316
|
+
<UserRoundCheckIcon size={16} className="text-foreground" />
|
|
317
|
+
</Button>
|
|
318
|
+
</View>
|
|
319
|
+
);
|
|
320
|
+
};
|
|
@@ -43,6 +43,7 @@ const JamRoomInner = () => {
|
|
|
43
43
|
autoRsvpError,
|
|
44
44
|
shouldAutoRsvp,
|
|
45
45
|
capacityBlock,
|
|
46
|
+
removedFromJam,
|
|
46
47
|
canDirectJoin,
|
|
47
48
|
canRequestJoin,
|
|
48
49
|
handleJoin,
|
|
@@ -124,6 +125,20 @@ const JamRoomInner = () => {
|
|
|
124
125
|
);
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
if (removedFromJam) {
|
|
129
|
+
return (
|
|
130
|
+
<JamRoomPanel title={jamEvent.name}>
|
|
131
|
+
<ThemedText className="text-center text-sm">
|
|
132
|
+
{t('jams.room.removedFromJam')}
|
|
133
|
+
</ThemedText>
|
|
134
|
+
<JamRoomPanelLink
|
|
135
|
+
label={t('jams.room.viewEvent')}
|
|
136
|
+
onPress={() => router.navigate({ type: 'post', id: jamPost.id })}
|
|
137
|
+
/>
|
|
138
|
+
</JamRoomPanel>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
if (capacityBlock.blocked) {
|
|
128
143
|
return (
|
|
129
144
|
<JamCapacityGate
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import { useNavigation } from '@react-navigation/native';
|
|
6
6
|
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
7
7
|
import React, { ReactNode, useMemo } from 'react';
|
|
8
|
-
import { Linking, View } from 'react-native';
|
|
8
|
+
import { Linking, StyleProp, TextStyle, View } from 'react-native';
|
|
9
9
|
import Markdown, {
|
|
10
10
|
MarkdownIt,
|
|
11
11
|
tokensToAST,
|
|
@@ -27,16 +27,23 @@ import { PreviewLink } from '../preview-link';
|
|
|
27
27
|
import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
|
|
28
28
|
import { recordOutboundClick } from '@openpeepshq/react';
|
|
29
29
|
|
|
30
|
-
export type OpenpeepsMarkdownProps = MarkdownRenderProps
|
|
30
|
+
export type OpenpeepsMarkdownProps = MarkdownRenderProps & {
|
|
31
|
+
/** Text metrics override merged over the theme's paragraph/list styles. */
|
|
32
|
+
baseTextStyle?: StyleProp<TextStyle>;
|
|
33
|
+
};
|
|
31
34
|
|
|
32
35
|
export const OpenpeepsMarkdown = ({
|
|
33
36
|
source,
|
|
34
37
|
mentions = [],
|
|
35
38
|
linkPreviewMode = 'none',
|
|
36
39
|
newTab = false,
|
|
40
|
+
baseTextStyle,
|
|
37
41
|
}: OpenpeepsMarkdownProps) => {
|
|
38
42
|
const { colors } = useOpenPeepsTheme();
|
|
39
|
-
const styles = useMemo(
|
|
43
|
+
const styles = useMemo(
|
|
44
|
+
() => markdownTheme(colors, { baseTextStyle }),
|
|
45
|
+
[colors, baseTextStyle]
|
|
46
|
+
);
|
|
40
47
|
|
|
41
48
|
const navigation =
|
|
42
49
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|