@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.
- package/package.json +3 -3
- package/src/components/buttonOverflow.test.tsx +8 -0
- package/src/components/conversations/ConversationParticipantsModal.tsx +1 -6
- package/src/components/icons/index.ts +2 -0
- package/src/components/jams/JamChatDrawer.test.tsx +263 -0
- package/src/components/jams/JamChatDrawer.tsx +117 -52
- package/src/components/jams/JamConference.tsx +5 -0
- package/src/components/jams/JamParticipantConference.tsx +7 -4
- package/src/components/jams/JamPeopleDrawer.test.tsx +216 -0
- package/src/components/jams/JamPeopleDrawer.tsx +32 -2
- package/src/components/jams/JamRoomIndicators.test.tsx +190 -38
- package/src/components/jams/JamRoomIndicators.tsx +62 -20
- package/src/components/jams/useTrackSubscriptionBump.test.ts +294 -0
- package/src/components/jams/useTrackSubscriptionBump.ts +44 -0
- package/src/components/navigation/nativeRouter.tsx +13 -3
- package/src/components/notifications/NotificationHeaderActions.test.tsx +285 -0
- package/src/components/notifications/NotificationHeaderActions.tsx +91 -4
- package/src/components/notifications/NotificationsList.test.tsx +109 -0
- package/src/components/notifications/NotificationsList.tsx +13 -3
- package/src/components/notifications/types/Reaction.tsx +6 -2
- package/src/components/post/feed/events/EventsCalendar.test.tsx +33 -18
- package/src/components/post/pieces/PostActions.test.tsx +244 -0
- package/src/components/post/pieces/PostActions.tsx +74 -49
- package/src/components/post/pieces/ReactionPicker.test.tsx +184 -0
- package/src/components/post/pieces/ReactionPicker.tsx +58 -0
- package/src/components/post/pieces/ShareMenu.test.tsx +217 -0
- package/src/components/post/pieces/ShareMenu.tsx +107 -61
- package/src/components/post/pieces/index.ts +1 -0
- package/src/components/post/pieces/modals/ReactionsModal.tsx +1 -1
- package/src/components/post/post-form/VisibilitySheet.test.tsx +153 -0
- package/src/components/post/post-form/VisibilitySheet.tsx +6 -5
- package/src/components/profile/Avatar.test.tsx +147 -0
- package/src/components/profile/Avatar.tsx +26 -0
- package/src/components/profile/ProfileCard.test.tsx +165 -8
- package/src/components/profile/ProfileCard.tsx +63 -10
- package/src/components/profile/ProfileSelector.test.tsx +147 -5
- package/src/components/profile/ProfileSelector.tsx +64 -18
- package/src/pages/Notifications.tsx +3 -1
- package/src/pages/Welcome.test.tsx +166 -0
- package/src/pages/Welcome.tsx +50 -4
- package/src/pages/conversations/New.test.tsx +340 -0
- package/src/pages/conversations/New.tsx +35 -30
- package/src/pages/events/Index.tsx +4 -1
- package/src/pages/events/My.tsx +1 -1
- package/src/pages/groups/Show.tsx +1 -1
- package/src/theme/useThemeOpacity.test.ts +70 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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,8 +142,8 @@
|
|
|
142
142
|
"timezones-list": "^3.1.0",
|
|
143
143
|
"validator": "^13.15.23",
|
|
144
144
|
"zustand": "^5.0.3",
|
|
145
|
-
"@openpeepshq/common": "^0.
|
|
146
|
-
"@openpeepshq/react": "^0.
|
|
145
|
+
"@openpeepshq/common": "^0.11.0",
|
|
146
|
+
"@openpeepshq/react": "^0.17.0",
|
|
147
147
|
"@openpeepshq/fetch-client": "^0.2.1"
|
|
148
148
|
},
|
|
149
149
|
"devDependencies": {
|
|
@@ -126,6 +126,14 @@ jest.mock('./ui/avatar', () => ({
|
|
|
126
126
|
AvatarImage: () => null,
|
|
127
127
|
AvatarFallback: () => null,
|
|
128
128
|
}));
|
|
129
|
+
// ProfileAvatar now renders SVG avatars through ui/svg-image, which imports
|
|
130
|
+
// react-native-svg (unusable under this test's partial react-native mock).
|
|
131
|
+
// Stub the leaf like the sibling ui/* mocks; the test profiles have no
|
|
132
|
+
// avatar, so it is never exercised.
|
|
133
|
+
jest.mock('./ui/svg-image', () => ({
|
|
134
|
+
SvgImage: (props: Record<string, unknown>) =>
|
|
135
|
+
React.createElement('SvgImage', props),
|
|
136
|
+
}));
|
|
129
137
|
jest.mock('./ui/themed-text', () => ({
|
|
130
138
|
ThemedText: el('ThemedText', { forwarded: true }),
|
|
131
139
|
TextClassContext: {
|
|
@@ -34,12 +34,7 @@ export const ConversationParticipantsModal = ({
|
|
|
34
34
|
</ThemedText>
|
|
35
35
|
</View>
|
|
36
36
|
{participants.map((profile) => (
|
|
37
|
-
<ProfileCard
|
|
38
|
-
key={profile.id}
|
|
39
|
-
profile={profile}
|
|
40
|
-
showAction={false}
|
|
41
|
-
hasAction={false}
|
|
42
|
-
/>
|
|
37
|
+
<ProfileCard key={profile.id} profile={profile} showAction={false} />
|
|
43
38
|
))}
|
|
44
39
|
</BaseSheet>
|
|
45
40
|
);
|
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
File,
|
|
96
96
|
Circle,
|
|
97
97
|
Settings2,
|
|
98
|
+
SlidersHorizontal,
|
|
98
99
|
MessageSquareOff,
|
|
99
100
|
MessageSquarePlus,
|
|
100
101
|
CircleSlash2,
|
|
@@ -248,6 +249,7 @@ export const FileIcon = iconWithClassName(File);
|
|
|
248
249
|
export const ScreenShareIcon = iconWithClassName(ScreenShare);
|
|
249
250
|
export const CircleIcon = iconWithClassName(Circle);
|
|
250
251
|
export const Settings2Icon = iconWithClassName(Settings2);
|
|
252
|
+
export const SlidersHorizontalIcon = iconWithClassName(SlidersHorizontal);
|
|
251
253
|
export const MessageSquareOffIcon = iconWithClassName(MessageSquareOff);
|
|
252
254
|
export const MessageSquarePlusIcon = iconWithClassName(MessageSquarePlus);
|
|
253
255
|
export const CircleSlash2Icon = iconWithClassName(CircleSlash2);
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the JAM chat drawer keyboard handling (issue #1705):
|
|
3
|
+
*
|
|
4
|
+
* - The drawer must present with an iOS-only KeyboardAvoidingView whose
|
|
5
|
+
* offset is the safe-area top inset (Android branch: disabled + no
|
|
6
|
+
* behavior), on both platform sides.
|
|
7
|
+
* - It must never crash on hosts that mount no SafeAreaProvider: the
|
|
8
|
+
* react-native-safe-area-context mock below reproduces the 5.8.0
|
|
9
|
+
* semantics (context defaults to null; the hook throws on null) so the
|
|
10
|
+
* drawer's context-based read is what keeps it alive, not a hook mock.
|
|
11
|
+
* - It must re-pin the newest message via the keyboardDidShow listener
|
|
12
|
+
* (the base-sheet.tsx pattern); that re-pin is iOS-only — on Android the
|
|
13
|
+
* host's adjustResize handles keyboard avoidance, so no JS listener.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const React = require('react');
|
|
17
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
18
|
+
|
|
19
|
+
// Mirrors react-native-safe-area-context@5.8.0: the context defaults to
|
|
20
|
+
// null and useSafeAreaInsets() throws on null (verified in the installed
|
|
21
|
+
// lib/commonjs/SafeAreaContext.js). SafeAreaProvider is stubbed to set the
|
|
22
|
+
// context, as the real one does once native metrics arrive.
|
|
23
|
+
const SafeAreaInsetsContext = React.createContext<{ top: number } | null>(null);
|
|
24
|
+
const throwingUseSafeAreaInsets = jest.fn(() => {
|
|
25
|
+
throw new Error(
|
|
26
|
+
'No safe area value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.'
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
const insets59 = { top: 59, bottom: 34, left: 0, right: 0 };
|
|
30
|
+
|
|
31
|
+
jest.mock('react-native-safe-area-context', () => ({
|
|
32
|
+
SafeAreaInsetsContext,
|
|
33
|
+
useSafeAreaInsets: throwingUseSafeAreaInsets,
|
|
34
|
+
// The real 5.8.0 provider only exposes the context once native metrics
|
|
35
|
+
// arrive; this stub models the settled state (context set immediately).
|
|
36
|
+
SafeAreaProvider: (props: Record<string, unknown>) =>
|
|
37
|
+
React.createElement(
|
|
38
|
+
'SafeAreaProvider',
|
|
39
|
+
null,
|
|
40
|
+
React.createElement(
|
|
41
|
+
SafeAreaInsetsContext.Provider,
|
|
42
|
+
{ value: insets59 },
|
|
43
|
+
props.children
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
const platformState = { os: 'ios' as 'ios' | 'android' };
|
|
49
|
+
const flatListState = { handles: [] as Array<{ scrollToEnd: jest.Mock }> };
|
|
50
|
+
// Records the Keyboard listeners the drawer subscribes to, so a test can
|
|
51
|
+
// fire keyboardDidShow the way the platform does (not by calling a
|
|
52
|
+
// component prop directly).
|
|
53
|
+
const keyboardState = {
|
|
54
|
+
listeners: [] as Array<{ type: string; cb: jest.Mock }>,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
jest.mock('react-native', () => ({
|
|
58
|
+
Platform: {
|
|
59
|
+
get OS() {
|
|
60
|
+
return platformState.os;
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
View: (props: Record<string, unknown>) =>
|
|
64
|
+
React.createElement('View', props, props.children),
|
|
65
|
+
Pressable: (props: Record<string, unknown>) =>
|
|
66
|
+
React.createElement('Pressable', props, props.children),
|
|
67
|
+
ActivityIndicator: (props: Record<string, unknown>) =>
|
|
68
|
+
React.createElement('ActivityIndicator', props),
|
|
69
|
+
FlatList: Object.assign(
|
|
70
|
+
React.forwardRef((props: Record<string, unknown>, ref: unknown) => {
|
|
71
|
+
const handle = { scrollToEnd: jest.fn() };
|
|
72
|
+
flatListState.handles.push(handle);
|
|
73
|
+
React.useImperativeHandle(
|
|
74
|
+
ref as React.Ref<{ scrollToEnd: jest.Mock }>,
|
|
75
|
+
() => handle
|
|
76
|
+
);
|
|
77
|
+
return React.createElement('FlatList', props, props.children);
|
|
78
|
+
}),
|
|
79
|
+
{ displayName: 'FlatList' }
|
|
80
|
+
),
|
|
81
|
+
KeyboardAvoidingView: (props: Record<string, unknown>) =>
|
|
82
|
+
React.createElement('KeyboardAvoidingView', props, props.children),
|
|
83
|
+
Keyboard: {
|
|
84
|
+
addListener: (type: string, cb: jest.Mock) => {
|
|
85
|
+
const entry = { type, cb };
|
|
86
|
+
keyboardState.listeners.push(entry);
|
|
87
|
+
return {
|
|
88
|
+
remove: () => {
|
|
89
|
+
const idx = keyboardState.listeners.indexOf(entry);
|
|
90
|
+
if (idx >= 0) keyboardState.listeners.splice(idx, 1);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
jest.mock('react-i18next', () => ({
|
|
98
|
+
useTranslation: () => ({ t: (key: string) => key }),
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
102
|
+
useJamChat: () => ({
|
|
103
|
+
messages: [],
|
|
104
|
+
mentionProfiles: [],
|
|
105
|
+
isLoading: false,
|
|
106
|
+
isFetchingNextPage: false,
|
|
107
|
+
loadOlder: jest.fn(),
|
|
108
|
+
newMessage: '',
|
|
109
|
+
setNewMessage: jest.fn(),
|
|
110
|
+
isSending: false,
|
|
111
|
+
send: jest.fn(async () => true),
|
|
112
|
+
}),
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
jest.mock('@livekit/react-native', () => ({
|
|
116
|
+
useParticipants: () => [],
|
|
117
|
+
}));
|
|
118
|
+
|
|
119
|
+
jest.mock('@openpeepshq/common', () => ({}));
|
|
120
|
+
|
|
121
|
+
jest.mock('./JamDrawer', () => ({
|
|
122
|
+
JamDrawer: (props: Record<string, unknown>) =>
|
|
123
|
+
React.createElement('JamDrawer', props, props.children),
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
jest.mock('./JamChatMessage', () => ({
|
|
127
|
+
JamChatMessage: (props: Record<string, unknown>) =>
|
|
128
|
+
React.createElement('JamChatMessage', props),
|
|
129
|
+
}));
|
|
130
|
+
|
|
131
|
+
jest.mock('../icons/index', () => ({
|
|
132
|
+
SendHorizontalIcon: (props: Record<string, unknown>) =>
|
|
133
|
+
React.createElement('SendHorizontalIcon', props),
|
|
134
|
+
}));
|
|
135
|
+
|
|
136
|
+
jest.mock('../ui/textarea', () => ({
|
|
137
|
+
Textarea: (props: Record<string, unknown>) =>
|
|
138
|
+
React.createElement('Textarea', props),
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
jest.mock('../ui/themed-text', () => ({
|
|
142
|
+
ThemedText: (props: Record<string, unknown>) =>
|
|
143
|
+
React.createElement('ThemedText', props, props.children),
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
import { JamChatDrawer } from './JamChatDrawer';
|
|
147
|
+
|
|
148
|
+
const hostProvider = { value: insets59 };
|
|
149
|
+
|
|
150
|
+
const renderDrawer = (
|
|
151
|
+
props: { readOnly?: boolean } = {},
|
|
152
|
+
wrapInHostProvider: boolean = true
|
|
153
|
+
) => {
|
|
154
|
+
let tree: ReturnType<typeof ReactTestRenderer.create>;
|
|
155
|
+
ReactTestRenderer.act(() => {
|
|
156
|
+
const drawer = React.createElement(JamChatDrawer, {
|
|
157
|
+
open: true,
|
|
158
|
+
onClose: jest.fn(),
|
|
159
|
+
...props,
|
|
160
|
+
});
|
|
161
|
+
tree = ReactTestRenderer.create(
|
|
162
|
+
wrapInHostProvider
|
|
163
|
+
? React.createElement(
|
|
164
|
+
SafeAreaInsetsContext.Provider,
|
|
165
|
+
hostProvider,
|
|
166
|
+
drawer
|
|
167
|
+
)
|
|
168
|
+
: drawer
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
return tree;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
describe('JamChatDrawer keyboard handling (issue #1705)', () => {
|
|
175
|
+
afterEach(() => {
|
|
176
|
+
platformState.os = 'ios';
|
|
177
|
+
flatListState.handles = [];
|
|
178
|
+
keyboardState.listeners = [];
|
|
179
|
+
throwingUseSafeAreaInsets.mockClear();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('presents with the keyboard-avoiding list and composer on iOS', () => {
|
|
183
|
+
const tree = renderDrawer();
|
|
184
|
+
expect(tree.root.findByType('KeyboardAvoidingView')).toBeDefined();
|
|
185
|
+
expect(tree.root.findByType('FlatList')).toBeDefined();
|
|
186
|
+
expect(
|
|
187
|
+
tree.root.findByProps({ placeholder: 'jams.chat.messagePlaceholder' })
|
|
188
|
+
).toBeDefined();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('avoids the keyboard on iOS with the safe-area-top offset', () => {
|
|
192
|
+
const tree = renderDrawer();
|
|
193
|
+
const kav = tree.root.findByType('KeyboardAvoidingView');
|
|
194
|
+
expect(kav.props.enabled).toBe(true);
|
|
195
|
+
expect(kav.props.behavior).toBe('padding');
|
|
196
|
+
expect(kav.props.keyboardVerticalOffset).toBe(59);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('disables the keyboard avoidance on Android (host adjustResize handles it)', () => {
|
|
200
|
+
platformState.os = 'android';
|
|
201
|
+
const tree = renderDrawer();
|
|
202
|
+
const kav = tree.root.findByType('KeyboardAvoidingView');
|
|
203
|
+
expect(kav.props.enabled).toBe(false);
|
|
204
|
+
expect(kav.props.behavior).toBeUndefined();
|
|
205
|
+
// Android keyboard avoidance is the host's adjustResize, so the
|
|
206
|
+
// cross-platform contract is: no keyboardDidShow re-pin subscription.
|
|
207
|
+
expect(keyboardState.listeners).toHaveLength(0);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('renders without a host SafeAreaProvider instead of throwing', () => {
|
|
211
|
+
// No provider above: the context is null. If the drawer read the hook
|
|
212
|
+
// instead of the context, this render throws (real 5.8.0 semantics).
|
|
213
|
+
const tree = renderDrawer({}, false);
|
|
214
|
+
expect(throwingUseSafeAreaInsets).not.toHaveBeenCalled();
|
|
215
|
+
// The drawer serves its own provider, so the offset still resolves.
|
|
216
|
+
expect(tree.root.findByType('SafeAreaProvider')).toBeDefined();
|
|
217
|
+
const kav = tree.root.findByType('KeyboardAvoidingView');
|
|
218
|
+
expect(kav.props.keyboardVerticalOffset).toBe(59);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('keeps the host provider authoritative (no nested provider)', () => {
|
|
222
|
+
const tree = renderDrawer();
|
|
223
|
+
expect(tree.root.findAllByType('SafeAreaProvider')).toHaveLength(0);
|
|
224
|
+
const kav = tree.root.findByType('KeyboardAvoidingView');
|
|
225
|
+
expect(kav.props.keyboardVerticalOffset).toBe(59);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('re-pins the newest message when the keyboard shows', () => {
|
|
229
|
+
renderDrawer();
|
|
230
|
+
// The re-pin rides the keyboardDidShow listener (base-sheet.tsx pattern).
|
|
231
|
+
// Fire the subscriber the way the platform would.
|
|
232
|
+
const didShow = keyboardState.listeners.filter(
|
|
233
|
+
(l) => l.type === 'keyboardDidShow'
|
|
234
|
+
);
|
|
235
|
+
expect(didShow).toHaveLength(1);
|
|
236
|
+
const handle = flatListState.handles[flatListState.handles.length - 1];
|
|
237
|
+
ReactTestRenderer.act(() => {
|
|
238
|
+
didShow[0].cb();
|
|
239
|
+
});
|
|
240
|
+
expect(handle.scrollToEnd).toHaveBeenCalledWith({ animated: true });
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('unsubscribes the keyboard listener when the drawer unmounts', () => {
|
|
244
|
+
const tree = renderDrawer();
|
|
245
|
+
expect(keyboardState.listeners).toHaveLength(1);
|
|
246
|
+
// Tearing down the drawer runs the effect cleanup, which removes the
|
|
247
|
+
// subscription.
|
|
248
|
+
ReactTestRenderer.act(() => {
|
|
249
|
+
tree.unmount();
|
|
250
|
+
});
|
|
251
|
+
expect(keyboardState.listeners).toHaveLength(0);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('renders read-only chat without a composer', () => {
|
|
255
|
+
const tree = renderDrawer({ readOnly: true });
|
|
256
|
+
expect(
|
|
257
|
+
tree.root.findAllByProps({ placeholder: 'jams.chat.messagePlaceholder' })
|
|
258
|
+
).toHaveLength(0);
|
|
259
|
+
expect(tree.root.findByType('FlatList')).toBeDefined();
|
|
260
|
+
// Read-only has no composer to re-pin; no keyboard subscription.
|
|
261
|
+
expect(keyboardState.listeners).toHaveLength(0);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
FlatList,
|
|
5
|
+
Keyboard,
|
|
6
|
+
KeyboardAvoidingView,
|
|
7
|
+
Platform,
|
|
8
|
+
Pressable,
|
|
9
|
+
View,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import {
|
|
12
|
+
SafeAreaInsetsContext,
|
|
13
|
+
SafeAreaProvider,
|
|
14
|
+
} from 'react-native-safe-area-context';
|
|
3
15
|
import { useParticipants } from '@livekit/react-native';
|
|
4
16
|
import { useTranslation } from 'react-i18next';
|
|
5
17
|
import { useJamChat } from '@openpeepshq/react';
|
|
@@ -16,13 +28,41 @@ export interface JamChatDrawerProps {
|
|
|
16
28
|
readOnly?: boolean;
|
|
17
29
|
}
|
|
18
30
|
|
|
31
|
+
/**
|
|
32
|
+
* The drawer reads the insets context directly (null without a provider
|
|
33
|
+
* instead of throwing) and, when the host has no root SafeAreaProvider,
|
|
34
|
+
* mounts a local one so the offset below — and any descendant
|
|
35
|
+
* useSafeAreaInsets() call — resolve. A real provider higher in the tree
|
|
36
|
+
* stays authoritative because it keeps the context set.
|
|
37
|
+
*/
|
|
19
38
|
export const JamChatDrawer = ({
|
|
20
39
|
open,
|
|
21
40
|
onClose,
|
|
22
41
|
readOnly = false,
|
|
42
|
+
}: JamChatDrawerProps) => {
|
|
43
|
+
const insets = React.useContext(SafeAreaInsetsContext);
|
|
44
|
+
const body = (
|
|
45
|
+
<JamChatDrawerBody open={open} onClose={onClose} readOnly={readOnly} />
|
|
46
|
+
);
|
|
47
|
+
if (insets != null) return body;
|
|
48
|
+
return <SafeAreaProvider>{body}</SafeAreaProvider>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const JamChatDrawerBody = ({
|
|
52
|
+
open,
|
|
53
|
+
onClose,
|
|
54
|
+
readOnly = false,
|
|
23
55
|
}: JamChatDrawerProps) => {
|
|
24
56
|
const { t } = useTranslation();
|
|
25
57
|
const participants = useParticipants();
|
|
58
|
+
const isIos = Platform.OS === 'ios';
|
|
59
|
+
// The offset is the screen-Y of the KAV's parent (the drawer root): the
|
|
60
|
+
// screen's safe-area view pads it by insets.top. The title bar and the
|
|
61
|
+
// gap-3 are siblings above the KAV in that parent — part of the KAV's own
|
|
62
|
+
// frame — so do not add them to the offset. The body only renders where a
|
|
63
|
+
// provider has settled non-null insets (the wrapper's decision), so the
|
|
64
|
+
// read below is plain.
|
|
65
|
+
const keyboardVerticalOffset = React.useContext(SafeAreaInsetsContext)!.top;
|
|
26
66
|
const {
|
|
27
67
|
messages,
|
|
28
68
|
mentionProfiles,
|
|
@@ -45,6 +85,17 @@ export const JamChatDrawer = ({
|
|
|
45
85
|
return () => clearTimeout(timeout);
|
|
46
86
|
}, [open, messages.length]);
|
|
47
87
|
|
|
88
|
+
// Re-pin the newest message on keyboardDidShow (the base-sheet.tsx
|
|
89
|
+
// pattern); iOS-only — Android keyboard avoidance is the host's
|
|
90
|
+
// adjustResize, so no JS re-pin there.
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!open || readOnly || !isIos) return;
|
|
93
|
+
const sub = Keyboard.addListener('keyboardDidShow', () =>
|
|
94
|
+
listRef.current?.scrollToEnd({ animated: true })
|
|
95
|
+
);
|
|
96
|
+
return () => sub.remove();
|
|
97
|
+
}, [open, readOnly, isIos]);
|
|
98
|
+
|
|
48
99
|
const handleSendMessage = async () => {
|
|
49
100
|
if (!(await send())) return;
|
|
50
101
|
listRef.current?.scrollToEnd({ animated: true });
|
|
@@ -56,59 +107,73 @@ export const JamChatDrawer = ({
|
|
|
56
107
|
|
|
57
108
|
return (
|
|
58
109
|
<JamDrawer title={t('jams.drawer.chatTitle')} onClose={onClose}>
|
|
59
|
-
|
|
60
|
-
|
|
110
|
+
{/* KeyboardAvoidingView is a no-op on Android — keyboard avoidance
|
|
111
|
+
there relies on the host app's windowSoftInputMode. The example
|
|
112
|
+
app ships adjustResize; the shipping host is confirmed separately
|
|
113
|
+
(replan §6). Keeping the KAV disabled on Android avoids a
|
|
114
|
+
double-shrink flash next to the OS resize. */}
|
|
115
|
+
<KeyboardAvoidingView
|
|
61
116
|
className="flex-1"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
117
|
+
behavior={isIos ? 'padding' : undefined}
|
|
118
|
+
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
119
|
+
enabled={isIos}
|
|
120
|
+
>
|
|
121
|
+
{/* flex-1 is load-bearing here — without it FlatList sizes to
|
|
122
|
+
content and does not fill the remaining KAV space. */}
|
|
123
|
+
<FlatList
|
|
124
|
+
ref={listRef}
|
|
125
|
+
className="flex-1"
|
|
126
|
+
data={messages}
|
|
127
|
+
keyExtractor={(message) => message.id}
|
|
128
|
+
contentContainerClassName="gap-4 px-2 pb-4"
|
|
129
|
+
// Older messages load when the user scrolls to the top (web: sentinel).
|
|
130
|
+
onStartReached={loadOlder}
|
|
131
|
+
onStartReachedThreshold={0.1}
|
|
132
|
+
ListHeaderComponent={
|
|
133
|
+
isFetchingNextPage ? (
|
|
134
|
+
<View className="items-center py-2">
|
|
135
|
+
<ActivityIndicator size="small" />
|
|
136
|
+
</View>
|
|
137
|
+
) : null
|
|
138
|
+
}
|
|
139
|
+
ListEmptyComponent={
|
|
140
|
+
!isLoading ? (
|
|
141
|
+
<ThemedText className="mt-4 text-center text-muted-foreground">
|
|
142
|
+
{t('jams.chat.noMessages')}
|
|
143
|
+
</ThemedText>
|
|
144
|
+
) : null
|
|
145
|
+
}
|
|
146
|
+
renderItem={({ item }) => (
|
|
147
|
+
<JamChatMessage message={item} mentionProfiles={mentionProfiles} />
|
|
148
|
+
)}
|
|
149
|
+
/>
|
|
86
150
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
151
|
+
{!readOnly ? (
|
|
152
|
+
<View className="w-full flex-row items-center gap-x-2 bg-background p-2">
|
|
153
|
+
<Textarea
|
|
154
|
+
editable={!isSending}
|
|
155
|
+
value={newMessage}
|
|
156
|
+
numberOfLines={1}
|
|
157
|
+
onChangeText={setNewMessage}
|
|
158
|
+
onSubmitEditing={() => void handleSendMessage()}
|
|
159
|
+
blurOnSubmit
|
|
160
|
+
className="min-h-0 flex-1 border-0"
|
|
161
|
+
placeholder={t('jams.chat.messagePlaceholder')}
|
|
162
|
+
/>
|
|
163
|
+
<Pressable
|
|
164
|
+
accessibilityLabel={t('jams.chat.sendTitle')}
|
|
165
|
+
disabled={isSending}
|
|
166
|
+
onPress={() => void handleSendMessage()}
|
|
167
|
+
>
|
|
168
|
+
{isSending ? (
|
|
169
|
+
<ActivityIndicator size="small" />
|
|
170
|
+
) : (
|
|
171
|
+
<SendHorizontalIcon size={24} className="text-foreground" />
|
|
172
|
+
)}
|
|
173
|
+
</Pressable>
|
|
174
|
+
</View>
|
|
175
|
+
) : null}
|
|
176
|
+
</KeyboardAvoidingView>
|
|
112
177
|
</JamDrawer>
|
|
113
178
|
);
|
|
114
179
|
};
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { JamObserverShell } from './JamObserverShell';
|
|
15
15
|
import { JamParticipantConference } from './JamParticipantConference';
|
|
16
16
|
import { JamVideoLayout } from './JamVideoLayout';
|
|
17
|
+
import { useTrackSubscriptionBump } from './useTrackSubscriptionBump';
|
|
17
18
|
|
|
18
19
|
const JamObserverConference = () => {
|
|
19
20
|
const tracks = useTracks(
|
|
@@ -65,6 +66,10 @@ const JamObserverRoom = () => {
|
|
|
65
66
|
*/
|
|
66
67
|
export const JamConference = () => {
|
|
67
68
|
const observer = useJamObserver();
|
|
69
|
+
// Applied once here (rather than in each conference) so every useTracks
|
|
70
|
+
// consumer in the Jam tree — participant and observer — re-reads
|
|
71
|
+
// publication.track when a remote video track is (un)subscribed (#1808).
|
|
72
|
+
useTrackSubscriptionBump(useRoomContext());
|
|
68
73
|
|
|
69
74
|
if (observer) {
|
|
70
75
|
return <JamObserverRoom />;
|
|
@@ -24,8 +24,9 @@ import { JamFooter, type JamFooterProps } from './JamFooter';
|
|
|
24
24
|
import { JamPeopleDrawer } from './JamPeopleDrawer';
|
|
25
25
|
import {
|
|
26
26
|
JamNetworkQuality,
|
|
27
|
-
|
|
27
|
+
JamObserverBanner,
|
|
28
28
|
JamRecordingIndicator,
|
|
29
|
+
JamsBannerStack,
|
|
29
30
|
} from './JamRoomIndicators';
|
|
30
31
|
import { JamVideoLayout } from './JamVideoLayout';
|
|
31
32
|
|
|
@@ -94,9 +95,11 @@ const JamParticipantConferenceInner = () => {
|
|
|
94
95
|
|
|
95
96
|
return (
|
|
96
97
|
<View className="relative flex-1 overflow-hidden bg-background">
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
<JamsBannerStack>
|
|
99
|
+
<JamNetworkQuality />
|
|
100
|
+
<JamObserverBanner />
|
|
101
|
+
<JamRecordingIndicator />
|
|
102
|
+
</JamsBannerStack>
|
|
100
103
|
<View className="relative min-h-0 w-full flex-1 overflow-hidden p-2">
|
|
101
104
|
<View className="min-h-0 flex-1 overflow-hidden">
|
|
102
105
|
<View className="shrink-0 flex-row items-center">
|