@openpeepshq/rn-components 0.23.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 +4 -4
- 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/JamPeopleDrawer.test.tsx +104 -9
- package/src/components/jams/JamPeopleDrawer.tsx +48 -11
- package/src/components/jams/JamRequestJoin.test.tsx +163 -0
- package/src/components/jams/JamRequestJoin.tsx +31 -15
- package/src/components/jams/useLateTrackMediaStream.test.ts +139 -25
- package/src/components/jams/useLateTrackMediaStream.ts +62 -19
- package/src/components/navigation/main-navigator.tsx +5 -0
- package/src/components/navigation/nativeRouter.tsx +1 -0
- package/src/components/navigation/parent-back.ts +1 -0
- package/src/components/navigation/types/main.ts +1 -0
- 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/index.ts +1 -0
- package/src/pages/settings/Account.test.tsx +4 -0
- package/src/pages/settings/Account.tsx +14 -0
- package/src/pages/settings/CalendarFeed.test.tsx +269 -0
- package/src/pages/settings/CalendarFeed.tsx +77 -0
- package/src/pages/settings/Index.tsx +4 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web/native parity pin for the request-to-join phase machine (issue #1781).
|
|
3
|
+
*
|
|
4
|
+
* The web twin is pinned in `platform/react/src/components/jams/
|
|
5
|
+
* JamRequestJoin.test.tsx` (same idle → waiting → denied → re-request
|
|
6
|
+
* flow). The RN component gained the identical phase machine in this PR;
|
|
7
|
+
* this file pins it on native: the waiting copy renders only while the
|
|
8
|
+
* join stream is open, the denial copy renders after the stream reports a
|
|
9
|
+
* denial, and the request affordance returns so the guest can try again.
|
|
10
|
+
*
|
|
11
|
+
* Only RN, i18n, and the shared join hook are stubbed. `ThemedText` is the
|
|
12
|
+
* single text primitive the component renders through, so the mock records
|
|
13
|
+
* every rendered label in document order (`mockRenderedTexts`) — the
|
|
14
|
+
* assertions read that ordered log instead of walking the rendered tree.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const React = require('react');
|
|
18
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
19
|
+
|
|
20
|
+
let mockOnJoin: ((params: unknown) => void) | undefined;
|
|
21
|
+
let mockOnDenied: (() => void) | undefined;
|
|
22
|
+
let mockButtonOnPress: (() => void) | undefined;
|
|
23
|
+
let mockButtonComponent: unknown;
|
|
24
|
+
const mockRenderedTexts: string[] = [];
|
|
25
|
+
|
|
26
|
+
jest.mock('react-native', () => ({
|
|
27
|
+
View: (props: { children?: unknown; className?: string }) =>
|
|
28
|
+
React.createElement('View', null, props.children),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
jest.mock('react-i18next', () => ({
|
|
32
|
+
useTranslation: () => ({
|
|
33
|
+
// Values mirror `platform/i18n/src/locales/en.json` so the rendered
|
|
34
|
+
// copy pins the key usage.
|
|
35
|
+
t: (key: string) => {
|
|
36
|
+
if (key === 'jams.join.requestToJoin') return 'Request to join';
|
|
37
|
+
if (key === 'jams.join.waitingForModerator')
|
|
38
|
+
return 'Waiting for a moderator to let you in';
|
|
39
|
+
if (key === 'jams.join.rejected')
|
|
40
|
+
return 'The moderator declined your request to join';
|
|
41
|
+
return key;
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
// The hook is the only thing that talks to the join stream; capturing its
|
|
47
|
+
// callbacks lets the test drive the denied transition directly (a real
|
|
48
|
+
// stream would emit `{ denied: true }`).
|
|
49
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
50
|
+
apiErrorMessage: () => '',
|
|
51
|
+
useJoinWaitingRoomToken: (
|
|
52
|
+
onJoin: (params: unknown) => void,
|
|
53
|
+
_onError: unknown,
|
|
54
|
+
onDenied?: () => void
|
|
55
|
+
) => {
|
|
56
|
+
mockOnJoin = onJoin;
|
|
57
|
+
mockOnDenied = onDenied;
|
|
58
|
+
},
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
jest.mock('../ui/button', () => {
|
|
62
|
+
mockButtonComponent = (props: {
|
|
63
|
+
children?: unknown;
|
|
64
|
+
onPress?: () => void;
|
|
65
|
+
}) => {
|
|
66
|
+
mockButtonOnPress = props.onPress;
|
|
67
|
+
return React.createElement('Button', null, props.children);
|
|
68
|
+
};
|
|
69
|
+
return { Button: mockButtonComponent };
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
jest.mock('../ui/themed-text', () => ({
|
|
73
|
+
ThemedText: (props: { children?: unknown; className?: string }) => {
|
|
74
|
+
const c = props.children;
|
|
75
|
+
if (typeof c === 'string' && c) mockRenderedTexts.push(c);
|
|
76
|
+
return React.createElement('ThemedText', { className: props.className }, c);
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
const { JamRequestJoin } = require('./JamRequestJoin');
|
|
81
|
+
|
|
82
|
+
const pressButton = () => {
|
|
83
|
+
ReactTestRenderer.act(() => {
|
|
84
|
+
mockButtonOnPress?.();
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
describe('JamRequestJoin denied phase (RN)', () => {
|
|
89
|
+
let tree: ReactTestRenderer.ReactTestRenderer | undefined;
|
|
90
|
+
|
|
91
|
+
beforeEach(() => {
|
|
92
|
+
mockOnJoin = undefined;
|
|
93
|
+
mockOnDenied = undefined;
|
|
94
|
+
mockButtonOnPress = undefined;
|
|
95
|
+
mockRenderedTexts.length = 0;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
afterEach(() => {
|
|
99
|
+
ReactTestRenderer.act(() => {
|
|
100
|
+
tree?.unmount();
|
|
101
|
+
});
|
|
102
|
+
tree = undefined;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('shows the rejection message and offers the request again after a denial', () => {
|
|
106
|
+
ReactTestRenderer.act(() => {
|
|
107
|
+
tree = ReactTestRenderer.create(
|
|
108
|
+
React.createElement(JamRequestJoin, { onJoin: () => {} })
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Idle: only the request button, no waiting or rejection copy.
|
|
113
|
+
expect(mockButtonOnPress).toBeDefined();
|
|
114
|
+
expect(mockRenderedTexts).toEqual(['Request to join']);
|
|
115
|
+
expect(mockOnJoin).toBeUndefined();
|
|
116
|
+
expect(mockOnDenied).toBeUndefined();
|
|
117
|
+
|
|
118
|
+
// Requesting starts the waiting phase (the join stream is opened).
|
|
119
|
+
pressButton();
|
|
120
|
+
expect(mockOnJoin).toBeDefined();
|
|
121
|
+
expect(mockOnDenied).toBeDefined();
|
|
122
|
+
expect(mockRenderedTexts).toContain(
|
|
123
|
+
'Waiting for a moderator to let you in'
|
|
124
|
+
);
|
|
125
|
+
expect(mockRenderedTexts).not.toContain('The moderator declined');
|
|
126
|
+
// The request button is replaced by the waiting copy.
|
|
127
|
+
expect(
|
|
128
|
+
(tree as ReactTestRenderer.ReactTestRenderer).root.findAllByType(
|
|
129
|
+
mockButtonComponent as never
|
|
130
|
+
)
|
|
131
|
+
).toHaveLength(0);
|
|
132
|
+
|
|
133
|
+
// The stream reports a denial: the phase switches to denied.
|
|
134
|
+
mockRenderedTexts.length = 0;
|
|
135
|
+
ReactTestRenderer.act(() => {
|
|
136
|
+
mockOnDenied?.();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// The rejection copy is shown and the request is offered again; the
|
|
140
|
+
// waiting copy is gone (asserted on the phase's own render, since the
|
|
141
|
+
// log accumulates across renders).
|
|
142
|
+
expect(mockRenderedTexts).toEqual([
|
|
143
|
+
'The moderator declined your request to join',
|
|
144
|
+
'Request to join',
|
|
145
|
+
]);
|
|
146
|
+
expect(mockButtonOnPress).toBeDefined();
|
|
147
|
+
|
|
148
|
+
// Requesting again goes back to the waiting phase.
|
|
149
|
+
mockRenderedTexts.length = 0;
|
|
150
|
+
pressButton();
|
|
151
|
+
expect(mockRenderedTexts).toContain(
|
|
152
|
+
'Waiting for a moderator to let you in'
|
|
153
|
+
);
|
|
154
|
+
expect(mockRenderedTexts).not.toContain(
|
|
155
|
+
'The moderator declined your request to join'
|
|
156
|
+
);
|
|
157
|
+
expect(
|
|
158
|
+
(tree as ReactTestRenderer.ReactTestRenderer).root.findAllByType(
|
|
159
|
+
mockButtonComponent as never
|
|
160
|
+
)
|
|
161
|
+
).toHaveLength(0);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
@@ -16,8 +16,10 @@ export interface JamRequestJoinProps {
|
|
|
16
16
|
|
|
17
17
|
const JamWaitingRoomListener = ({
|
|
18
18
|
onJoin,
|
|
19
|
+
onDenied,
|
|
19
20
|
}: {
|
|
20
21
|
onJoin: JamRequestJoinProps['onJoin'];
|
|
22
|
+
onDenied: () => void;
|
|
21
23
|
}) => {
|
|
22
24
|
const { t } = useTranslation();
|
|
23
25
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -33,13 +35,17 @@ const JamWaitingRoomListener = ({
|
|
|
33
35
|
[onJoin]
|
|
34
36
|
);
|
|
35
37
|
|
|
36
|
-
useJoinWaitingRoomToken(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
useJoinWaitingRoomToken(
|
|
39
|
+
joinAndClearError,
|
|
40
|
+
(e?: SseError) => {
|
|
41
|
+
// Reuse the shared key→message mapping (`errorKey ?? key`, translate
|
|
42
|
+
// `error.*` keys). The SSE path passes an empty fallback so a keyless,
|
|
43
|
+
// message-less error renders nothing rather than a generic "Error".
|
|
44
|
+
const message = apiErrorMessage(e, t, '');
|
|
45
|
+
setError(message.length > 0 ? message : null);
|
|
46
|
+
},
|
|
47
|
+
onDenied
|
|
48
|
+
);
|
|
43
49
|
|
|
44
50
|
return error ? (
|
|
45
51
|
<ThemedText className="text-center text-sm text-destructive">
|
|
@@ -50,23 +56,33 @@ const JamWaitingRoomListener = ({
|
|
|
50
56
|
|
|
51
57
|
export const JamRequestJoin = ({ onJoin }: JamRequestJoinProps) => {
|
|
52
58
|
const { t } = useTranslation();
|
|
53
|
-
const [
|
|
59
|
+
const [phase, setPhase] = useState<'idle' | 'waiting' | 'denied'>('idle');
|
|
54
60
|
|
|
55
61
|
return (
|
|
56
62
|
<View className="w-full flex-1 items-center justify-center gap-4 p-4">
|
|
57
|
-
{
|
|
63
|
+
{phase === 'waiting' ? (
|
|
58
64
|
<>
|
|
59
|
-
<JamWaitingRoomListener
|
|
65
|
+
<JamWaitingRoomListener
|
|
66
|
+
onJoin={onJoin}
|
|
67
|
+
onDenied={() => setPhase('denied')}
|
|
68
|
+
/>
|
|
60
69
|
<ThemedText className="text-center text-sm text-muted-foreground">
|
|
61
70
|
{t('jams.join.waitingForModerator')}
|
|
62
71
|
</ThemedText>
|
|
63
72
|
</>
|
|
64
73
|
) : (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
<>
|
|
75
|
+
{phase === 'denied' ? (
|
|
76
|
+
<ThemedText className="text-center text-sm text-muted-foreground">
|
|
77
|
+
{t('jams.join.rejected')}
|
|
78
|
+
</ThemedText>
|
|
79
|
+
) : null}
|
|
80
|
+
<Button onPress={() => setPhase('waiting')}>
|
|
81
|
+
<ThemedText className="text-primary-foreground">
|
|
82
|
+
{t('jams.join.requestToJoin')}
|
|
83
|
+
</ThemedText>
|
|
84
|
+
</Button>
|
|
85
|
+
</>
|
|
70
86
|
)}
|
|
71
87
|
</View>
|
|
72
88
|
);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* useLateTrackMediaStream: emits a changing `remountKey` when the track's
|
|
3
|
-
* media stream gains its first video track (and
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* media stream gains its first video track (and on the bounded retry
|
|
4
|
+
* schedule after), so the screen-share VideoTrack's native view re-runs its
|
|
5
|
+
* one-shot `streamURL` attach until it can succeed. The non-obvious part: on
|
|
6
|
+
* the first share of a Jam the receiver renegotiates, so the native track
|
|
7
|
+
* registration can land seconds after the JS-side SDP apply — past the tight
|
|
8
|
+
* burst — which is why the schedule adds a sparse backoff tail.
|
|
8
9
|
*/
|
|
9
10
|
import React, { act } from 'react';
|
|
10
11
|
import TestRenderer from 'react-test-renderer';
|
|
@@ -22,11 +23,12 @@ const makeMediaStream = (initialVideoTracks = 0) => {
|
|
|
22
23
|
const index = listeners.indexOf(listener);
|
|
23
24
|
if (index !== -1) listeners.splice(index, 1);
|
|
24
25
|
},
|
|
25
|
-
// Test
|
|
26
|
+
// Test helpers, not part of the real MediaStream API.
|
|
26
27
|
addVideoTrack() {
|
|
27
28
|
videoTracks.push({});
|
|
28
29
|
listeners.forEach((listener) => listener());
|
|
29
30
|
},
|
|
31
|
+
listenerCount: () => listeners.length,
|
|
30
32
|
};
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -136,9 +138,10 @@ describe('useLateTrackMediaStream', () => {
|
|
|
136
138
|
});
|
|
137
139
|
expect(hook.current.remountKey).toBe(4);
|
|
138
140
|
|
|
139
|
-
// The burst is bounded:
|
|
141
|
+
// The burst is bounded at 3 remounts: just before the tail's first
|
|
142
|
+
// tick (2 s after the burst ends) nothing further has bumped.
|
|
140
143
|
act(() => {
|
|
141
|
-
jest.advanceTimersByTime(
|
|
144
|
+
jest.advanceTimersByTime(1900);
|
|
142
145
|
});
|
|
143
146
|
expect(hook.current.remountKey).toBe(4);
|
|
144
147
|
hook.unmount();
|
|
@@ -147,23 +150,6 @@ describe('useLateTrackMediaStream', () => {
|
|
|
147
150
|
}
|
|
148
151
|
});
|
|
149
152
|
|
|
150
|
-
it('does not emit the burst for a stream that already has its track', () => {
|
|
151
|
-
jest.useFakeTimers();
|
|
152
|
-
try {
|
|
153
|
-
const hook = renderHook({ mediaStream: makeMediaStream(1) });
|
|
154
|
-
expect(hook.current.remountKey).toBe(0);
|
|
155
|
-
|
|
156
|
-
// No 0 → 1 transition ever happens, so no remount burst should fire.
|
|
157
|
-
act(() => {
|
|
158
|
-
jest.advanceTimersByTime(300 * 20);
|
|
159
|
-
});
|
|
160
|
-
expect(hook.current.remountKey).toBe(0);
|
|
161
|
-
hook.unmount();
|
|
162
|
-
} finally {
|
|
163
|
-
jest.useRealTimers();
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
|
|
167
153
|
it('follows the current stream when the track changes', () => {
|
|
168
154
|
jest.useFakeTimers();
|
|
169
155
|
try {
|
|
@@ -231,4 +217,132 @@ describe('useLateTrackMediaStream', () => {
|
|
|
231
217
|
jest.useRealTimers();
|
|
232
218
|
}
|
|
233
219
|
});
|
|
220
|
+
|
|
221
|
+
it('ignores a late addtrack on a stream that was swapped out', () => {
|
|
222
|
+
jest.useFakeTimers();
|
|
223
|
+
try {
|
|
224
|
+
const first = makeMediaStream(0);
|
|
225
|
+
const hook = renderHook({ mediaStream: first });
|
|
226
|
+
|
|
227
|
+
act(() => {
|
|
228
|
+
first.addVideoTrack();
|
|
229
|
+
});
|
|
230
|
+
expect(hook.current.remountKey).toBe(1);
|
|
231
|
+
|
|
232
|
+
// Swap to a stream that does not carry a track yet: the stale-listener
|
|
233
|
+
// regression lives here. The effect cleanup resets prevCountRef to 0
|
|
234
|
+
// for the new stream, so a surviving addtrack listener from the old
|
|
235
|
+
// stream would pass its own 0 → 1 check against the old stream and arm
|
|
236
|
+
// a full burst + tail of spurious remounts.
|
|
237
|
+
const second = makeMediaStream(0);
|
|
238
|
+
hook.rerender({ mediaStream: second });
|
|
239
|
+
expect(hook.current.remountKey).toBe(0);
|
|
240
|
+
|
|
241
|
+
act(() => {
|
|
242
|
+
first.addVideoTrack();
|
|
243
|
+
});
|
|
244
|
+
expect(hook.current.remountKey).toBe(0);
|
|
245
|
+
|
|
246
|
+
// Nothing the old stream does can bump the key at any horizon: the
|
|
247
|
+
// cleanup must have removed its listener and cleared its timers.
|
|
248
|
+
act(() => {
|
|
249
|
+
jest.advanceTimersByTime(300 * 4 + 2000 * 5);
|
|
250
|
+
});
|
|
251
|
+
expect(hook.current.remountKey).toBe(0);
|
|
252
|
+
hook.unmount();
|
|
253
|
+
} finally {
|
|
254
|
+
jest.useRealTimers();
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('removes its addtrack listener when the hook unmounts', () => {
|
|
259
|
+
jest.useFakeTimers();
|
|
260
|
+
try {
|
|
261
|
+
const stream = makeMediaStream(0);
|
|
262
|
+
const hook = renderHook({ mediaStream: stream });
|
|
263
|
+
expect(stream.listenerCount()).toBe(1);
|
|
264
|
+
|
|
265
|
+
hook.unmount();
|
|
266
|
+
expect(stream.listenerCount()).toBe(0);
|
|
267
|
+
|
|
268
|
+
// The dead stream can no longer drive the hook: a late track after
|
|
269
|
+
// unmount produces neither a state update nor a remount schedule.
|
|
270
|
+
act(() => {
|
|
271
|
+
stream.addVideoTrack();
|
|
272
|
+
jest.advanceTimersByTime(300 * 4 + 2000 * 5);
|
|
273
|
+
});
|
|
274
|
+
} finally {
|
|
275
|
+
jest.useRealTimers();
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('emits a sparse backoff tail after the burst for a slow first share', () => {
|
|
280
|
+
jest.useFakeTimers();
|
|
281
|
+
try {
|
|
282
|
+
const stream = makeMediaStream(0);
|
|
283
|
+
const hook = renderHook({ mediaStream: stream });
|
|
284
|
+
|
|
285
|
+
act(() => {
|
|
286
|
+
stream.addVideoTrack();
|
|
287
|
+
});
|
|
288
|
+
expect(hook.current.remountKey).toBe(1);
|
|
289
|
+
|
|
290
|
+
// Tight burst: keys 2..4 at 300/600/900 ms; the 4th tick (1200 ms)
|
|
291
|
+
// clears the burst and starts the tail.
|
|
292
|
+
act(() => {
|
|
293
|
+
jest.advanceTimersByTime(300 * 4);
|
|
294
|
+
});
|
|
295
|
+
expect(hook.current.remountKey).toBe(4);
|
|
296
|
+
|
|
297
|
+
// The first share of a Jam adds a new m-line, so the receiver
|
|
298
|
+
// renegotiates and the native stream can register its video track
|
|
299
|
+
// seconds after the JS-side SDP apply — past the burst. The tail
|
|
300
|
+
// remounts again at 2 s, 4 s, 6 s and 8 s after the burst (keys 5..8).
|
|
301
|
+
act(() => {
|
|
302
|
+
jest.advanceTimersByTime(2000);
|
|
303
|
+
});
|
|
304
|
+
expect(hook.current.remountKey).toBe(5);
|
|
305
|
+
act(() => {
|
|
306
|
+
jest.advanceTimersByTime(2000);
|
|
307
|
+
});
|
|
308
|
+
expect(hook.current.remountKey).toBe(6);
|
|
309
|
+
act(() => {
|
|
310
|
+
jest.advanceTimersByTime(2000);
|
|
311
|
+
});
|
|
312
|
+
expect(hook.current.remountKey).toBe(7);
|
|
313
|
+
act(() => {
|
|
314
|
+
jest.advanceTimersByTime(2000);
|
|
315
|
+
});
|
|
316
|
+
expect(hook.current.remountKey).toBe(8);
|
|
317
|
+
|
|
318
|
+
// The schedule is finite: the tail's 5th tick (10 s after the burst)
|
|
319
|
+
// clears the interval without bumping, so a long-lived tile settles to
|
|
320
|
+
// a stable key — no endless remounts.
|
|
321
|
+
act(() => {
|
|
322
|
+
jest.advanceTimersByTime(30000);
|
|
323
|
+
});
|
|
324
|
+
expect(hook.current.remountKey).toBe(8);
|
|
325
|
+
hook.unmount();
|
|
326
|
+
} finally {
|
|
327
|
+
jest.useRealTimers();
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('does not run the retry schedule for a stream that already has its track', () => {
|
|
332
|
+
jest.useFakeTimers();
|
|
333
|
+
try {
|
|
334
|
+
const hook = renderHook({ mediaStream: makeMediaStream(1) });
|
|
335
|
+
expect(hook.current.remountKey).toBe(0);
|
|
336
|
+
|
|
337
|
+
// No 0 -> 1 transition ever happens: no burst and no tail at any
|
|
338
|
+
// horizon, so an already-attached share never remounts.
|
|
339
|
+
act(() => {
|
|
340
|
+
jest.advanceTimersByTime(30000);
|
|
341
|
+
});
|
|
342
|
+
expect(hook.current.remountKey).toBe(0);
|
|
343
|
+
hook.unmount();
|
|
344
|
+
} finally {
|
|
345
|
+
jest.useRealTimers();
|
|
346
|
+
}
|
|
347
|
+
});
|
|
234
348
|
});
|
|
@@ -7,27 +7,49 @@ import type { MediaStream } from '@livekit/react-native-webrtc';
|
|
|
7
7
|
const asWebRtcStream = (track?: Track): MediaStream | undefined =>
|
|
8
8
|
track?.mediaStream as MediaStream | undefined;
|
|
9
9
|
|
|
10
|
-
// A single remount is not enough for
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
10
|
+
// A single remount is not enough for a late share: the JS stream reports its
|
|
11
|
+
// video track (SDP apply) before the native stream has the track registered
|
|
12
|
+
// (first frame / dynacast), so the native one-shot `streamURL` lookup that a
|
|
13
|
+
// remount triggers can run empty. The retry schedule below gives the attach a
|
|
14
|
+
// sequence of bounded chances to land while the native stream settles. Each
|
|
15
|
+
// extra remount is a cheap native view recreation, and the whole schedule only
|
|
16
|
+
// ever runs on the rare late-share path — an already-attached share never
|
|
17
|
+
// sees any of it.
|
|
18
18
|
//
|
|
19
|
-
// The
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
19
|
+
// The schedule has two parts:
|
|
20
|
+
//
|
|
21
|
+
// 1. A tight burst right after the first track appears: `RETRY_BURST_ATTEMPTS`
|
|
22
|
+
// = 4 ticks at `RETRY_BURST_INTERVAL_MS` = 300; the first three ticks bump
|
|
23
|
+
// (300/600/900 ms after the transition bump) and the fourth (1200 ms) is
|
|
24
|
+
// consumed by the interval-clear branch — so exactly 3 extra remounts land
|
|
25
|
+
// within ~1.2 s. This covers the warm-connection case (subsequent shares),
|
|
26
|
+
// where the native stream registers its track almost at the same time as
|
|
27
|
+
// the JS one.
|
|
28
|
+
//
|
|
29
|
+
// 2. A sparse tail: `RETRY_TAIL_ATTEMPTS` = 5 ticks at
|
|
30
|
+
// `RETRY_TAIL_INTERVAL_MS` = 2000 ms each — ticks 1–4 bump (remounts at
|
|
31
|
+
// 2 s, 4 s, 6 s and 8 s after the burst ends) and tick 5 (10 s) is
|
|
32
|
+
// consumed by the interval-clear branch, exactly as the burst's 4th tick
|
|
33
|
+
// clears it (the N constant counts ticks, the last one clears). The FIRST
|
|
34
|
+
// share in a Jam adds a new m-line, so the receiver renegotiates and
|
|
35
|
+
// re-establishes ICE before the native stream registers the video track —
|
|
36
|
+
// that can take several seconds, well past the ~1.2 s burst. The tail is
|
|
37
|
+
// the part that fixes that case (verified against the QA report: the
|
|
38
|
+
// initial share of a Jam stayed black while subsequent shares worked).
|
|
39
|
+
// After the tail's clear tick, the schedule is fully over and
|
|
40
|
+
// self-cleared: no further remounts and no live timers.
|
|
23
41
|
const RETRY_BURST_ATTEMPTS = 4;
|
|
24
42
|
const RETRY_BURST_INTERVAL_MS = 300;
|
|
43
|
+
const RETRY_TAIL_ATTEMPTS = 5;
|
|
44
|
+
const RETRY_TAIL_INTERVAL_MS = 2000;
|
|
25
45
|
|
|
26
46
|
export interface LateTrackMediaStream {
|
|
27
47
|
/**
|
|
28
|
-
* Changes when the stream gains its first video track and again on
|
|
29
|
-
*
|
|
30
|
-
*
|
|
48
|
+
* Changes when the stream gains its first video track and again on the
|
|
49
|
+
* bounded retry schedule (tight burst, then sparse backoff tail) while the
|
|
50
|
+
* native stream settles, so the native view re-runs its one-shot `streamURL`
|
|
51
|
+
* attach until it can succeed — including the first share of a Jam, whose
|
|
52
|
+
* renegotiation delays the native track registration past the burst window.
|
|
31
53
|
*/
|
|
32
54
|
remountKey: number;
|
|
33
55
|
}
|
|
@@ -41,16 +63,18 @@ export interface LateTrackMediaStream {
|
|
|
41
63
|
* that lookup runs before the stream carries its video track, iOS gives up (no
|
|
42
64
|
* retry) and the tile stays black until we leave and rejoin. Re-keying the
|
|
43
65
|
* `VideoTrack` with `remountKey` remounts the native view when the stream gains
|
|
44
|
-
* its video track — and again
|
|
45
|
-
*
|
|
66
|
+
* its video track — and again on the bounded retry schedule — so the one-shot
|
|
67
|
+
* lookup re-runs until it can succeed.
|
|
46
68
|
*
|
|
47
69
|
* The poll is not redundant with the `addtrack` listener: on the first share,
|
|
48
70
|
* `addtrack` fires inside the native SDP-apply batch, before the room re-emits
|
|
49
71
|
* the publication that mounts this layout — so the event can fire before the
|
|
50
72
|
* listener exists.
|
|
51
73
|
*
|
|
52
|
-
* Camera tiles
|
|
53
|
-
*
|
|
74
|
+
* Camera tiles use the same mechanism (see `JamCallParticipant`): a first
|
|
75
|
+
* mid-Jam camera publish has the same race — the JS track exists before the
|
|
76
|
+
* native stream carries its video track, so the one-shot attach needs the
|
|
77
|
+
* same late-track remount burst (#1808).
|
|
54
78
|
*/
|
|
55
79
|
export const useLateTrackMediaStream = (
|
|
56
80
|
track?: Track
|
|
@@ -70,6 +94,23 @@ export const useLateTrackMediaStream = (
|
|
|
70
94
|
|
|
71
95
|
let pollTimer: ReturnType<typeof setInterval> | undefined;
|
|
72
96
|
let burstTimer: ReturnType<typeof setInterval> | undefined;
|
|
97
|
+
let tailTimer: ReturnType<typeof setInterval> | undefined;
|
|
98
|
+
|
|
99
|
+
const startTail = () => {
|
|
100
|
+
// Sparse retries for the first share of a Jam: its m-line forces a
|
|
101
|
+
// receiver-side renegotiation, so the native stream can register its
|
|
102
|
+
// video track seconds after the JS-side SDP apply — past the tight
|
|
103
|
+
// burst. Remounts at 2 s, 4 s, 6 s and 8 s after the burst (ticks 1–4
|
|
104
|
+
// bump); the 5th tick (10 s) clears the interval and ends the schedule.
|
|
105
|
+
let extra = 0;
|
|
106
|
+
tailTimer = setInterval(() => {
|
|
107
|
+
if (++extra >= RETRY_TAIL_ATTEMPTS) {
|
|
108
|
+
clearInterval(tailTimer!);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
setRemountKey((key) => key + 1);
|
|
112
|
+
}, RETRY_TAIL_INTERVAL_MS);
|
|
113
|
+
};
|
|
73
114
|
|
|
74
115
|
const startBurst = () => {
|
|
75
116
|
// The first track just appeared: the view re-mounts once for it (key
|
|
@@ -81,6 +122,7 @@ export const useLateTrackMediaStream = (
|
|
|
81
122
|
burstTimer = setInterval(() => {
|
|
82
123
|
if (++extra >= RETRY_BURST_ATTEMPTS) {
|
|
83
124
|
clearInterval(burstTimer!);
|
|
125
|
+
startTail();
|
|
84
126
|
return;
|
|
85
127
|
}
|
|
86
128
|
setRemountKey((key) => key + 1);
|
|
@@ -114,6 +156,7 @@ export const useLateTrackMediaStream = (
|
|
|
114
156
|
return () => {
|
|
115
157
|
if (pollTimer) clearInterval(pollTimer);
|
|
116
158
|
if (burstTimer) clearInterval(burstTimer);
|
|
159
|
+
if (tailTimer) clearInterval(tailTimer);
|
|
117
160
|
mediaStream.removeEventListener('addtrack', refresh);
|
|
118
161
|
prevCountRef.current = 0;
|
|
119
162
|
};
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
AccountSettings,
|
|
28
28
|
ThemeSettings,
|
|
29
29
|
AccessTokensSettings,
|
|
30
|
+
CalendarFeedSettings,
|
|
30
31
|
FeedSettings,
|
|
31
32
|
BlockedSettings,
|
|
32
33
|
VideoPlayer,
|
|
@@ -153,6 +154,10 @@ export const MainNavigator = () => {
|
|
|
153
154
|
name="AccessTokensSettings"
|
|
154
155
|
component={AccessTokensSettings}
|
|
155
156
|
/>
|
|
157
|
+
<Stack.Screen
|
|
158
|
+
name="CalendarFeedSettings"
|
|
159
|
+
component={CalendarFeedSettings}
|
|
160
|
+
/>
|
|
156
161
|
<Stack.Screen name="BlockedSettings" component={BlockedSettings} />
|
|
157
162
|
<Stack.Screen name="LanguageSettings" component={LanguageSettings} />
|
|
158
163
|
<Stack.Screen name="TimezoneSettings" component={TimezoneSettings} />
|
|
@@ -21,6 +21,7 @@ const SETTINGS_SCREENS: Record<string, keyof MainStackParamList | undefined> = {
|
|
|
21
21
|
'language': 'LanguageSettings',
|
|
22
22
|
'timezone': 'TimezoneSettings',
|
|
23
23
|
'feed': 'FeedSettings',
|
|
24
|
+
'calendar-feed': 'CalendarFeedSettings',
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
const go = (name: string, params?: object) => {
|