livevoice-sdk-react-native 2.0.0 → 2.0.1
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/README.md +119 -7
- package/android/build.gradle +14 -3
- package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +89 -123
- package/android/src/main/java/io/livevoice/react/__SDK.kt +16 -2
- package/ios/LiveVoiceSdkReactNative.mm +110 -37
- package/ios/__SDK.h +16 -2
- package/lib/module/components/AudioOutputSwitchView.js +13 -13
- package/lib/module/components/AudioOutputSwitchView.js.map +1 -1
- package/lib/module/components/BrandingView.js +13 -11
- package/lib/module/components/BrandingView.js.map +1 -1
- package/lib/module/components/ChannelView.js +14 -11
- package/lib/module/components/ChannelView.js.map +1 -1
- package/lib/module/components/ErrorView.js +12 -10
- package/lib/module/components/ErrorView.js.map +1 -1
- package/lib/module/components/LiveVoiceView.js +141 -72
- package/lib/module/components/LiveVoiceView.js.map +1 -1
- package/lib/module/components/PlayButtonView.js +12 -10
- package/lib/module/components/PlayButtonView.js.map +1 -1
- package/lib/module/components/ReconnectingView.js +16 -13
- package/lib/module/components/ReconnectingView.js.map +1 -1
- package/lib/module/components/WarningView.js +12 -10
- package/lib/module/components/WarningView.js.map +1 -1
- package/lib/module/components/index.js +12 -10
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/index.js +14 -220
- package/lib/module/index.js.map +1 -1
- package/lib/module/sdk/LiveVoiceSdk.js +371 -0
- package/lib/module/sdk/LiveVoiceSdk.js.map +1 -0
- package/lib/module/sdk/LiveVoiceState.js +66 -0
- package/lib/module/sdk/LiveVoiceState.js.map +1 -0
- package/lib/module/specs/NativeLiveVoiceSdk.js +12 -10
- package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
- package/lib/module/util/Colors.js +12 -10
- package/lib/module/util/Colors.js.map +1 -1
- package/lib/module/util/ForegroundServiceConfig.js +21 -11
- package/lib/module/util/ForegroundServiceConfig.js.map +1 -1
- package/lib/module/util/PlayingState.js +12 -10
- package/lib/module/util/PlayingState.js.map +1 -1
- package/lib/module/util/Translations.js +12 -10
- package/lib/module/util/Translations.js.map +1 -1
- package/lib/module/util/logger.js +76 -0
- package/lib/module/util/logger.js.map +1 -0
- package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +1 -1
- package/lib/typescript/src/components/BrandingView.d.ts.map +1 -1
- package/lib/typescript/src/components/ChannelView.d.ts.map +1 -1
- package/lib/typescript/src/components/ErrorView.d.ts.map +1 -1
- package/lib/typescript/src/components/LiveVoiceView.d.ts +22 -0
- package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -1
- package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -1
- package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -1
- package/lib/typescript/src/components/WarningView.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -144
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts +210 -0
- package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts.map +1 -0
- package/lib/typescript/src/sdk/LiveVoiceState.d.ts +12 -0
- package/lib/typescript/src/sdk/LiveVoiceState.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts +3 -0
- package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -1
- package/lib/typescript/src/util/Colors.d.ts.map +1 -1
- package/lib/typescript/src/util/ForegroundServiceConfig.d.ts +7 -0
- package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +1 -1
- package/lib/typescript/src/util/PlayingState.d.ts.map +1 -1
- package/lib/typescript/src/util/Translations.d.ts.map +1 -1
- package/lib/typescript/src/util/UIState.d.ts +22 -2
- package/lib/typescript/src/util/UIState.d.ts.map +1 -1
- package/lib/typescript/src/util/logger.d.ts +23 -0
- package/lib/typescript/src/util/logger.d.ts.map +1 -0
- package/livevoice-sdk-react-native.podspec +14 -14
- package/package.json +16 -7
- package/src/components/AudioOutputSwitchView.tsx +13 -13
- package/src/components/BrandingView.tsx +13 -11
- package/src/components/ChannelView.tsx +14 -11
- package/src/components/ErrorView.tsx +12 -10
- package/src/components/LiveVoiceView.tsx +183 -92
- package/src/components/PlayButtonView.tsx +12 -10
- package/src/components/ReconnectingView.tsx +20 -13
- package/src/components/WarningView.tsx +12 -10
- package/src/components/index.tsx +12 -10
- package/src/index.tsx +19 -252
- package/src/sdk/LiveVoiceSdk.ts +408 -0
- package/src/sdk/LiveVoiceState.ts +89 -0
- package/src/specs/NativeLiveVoiceSdk.ts +16 -10
- package/src/util/Colors.ts +12 -10
- package/src/util/ForegroundServiceConfig.tsx +21 -11
- package/src/util/PlayingState.ts +12 -10
- package/src/util/Translations.ts +12 -10
- package/src/util/UIState.ts +30 -13
- package/src/util/logger.ts +92 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeLiveVoiceSdkSpec.java +0 -186
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +0 -28
- package/android/app/build/generated/source/codegen/jni/RNLiveVoiceSpec-generated.cpp +0 -235
- package/android/app/build/generated/source/codegen/jni/RNLiveVoiceSpec.h +0 -31
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +0 -341
- package/android/src/main/java/io/livevoice/react/Mappings.kt +0 -85
- package/android/src/main/java/io/livevoice/react/NativeModels.kt +0 -79
|
@@ -1,93 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
//
|
|
3
|
+
// This source file is part of the LiveVoice SDK project
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) LiveVoice GmbH
|
|
6
|
+
// Licensed under the MIT license
|
|
7
|
+
//
|
|
8
|
+
// See LICENSE for license information
|
|
9
|
+
//
|
|
10
|
+
// SPDX-License-Identifier: MIT
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
11
13
|
|
|
12
14
|
import {
|
|
13
|
-
type UiState,
|
|
14
|
-
type AvailableSubtitle,
|
|
15
|
-
getCurrentUiState,
|
|
16
|
-
onUiStateChanged,
|
|
17
15
|
startChannel,
|
|
18
16
|
stopChannel,
|
|
19
17
|
reconnect,
|
|
20
|
-
onAvailableSubtitleConfigsChanged,
|
|
21
|
-
onSubtitlesChanged,
|
|
22
|
-
getCurrentClaims,
|
|
23
|
-
BrandingView,
|
|
24
|
-
ErrorView,
|
|
25
|
-
ReconnectingView,
|
|
26
18
|
startSubtitles,
|
|
27
|
-
} from
|
|
19
|
+
} from '../sdk/LiveVoiceSdk';
|
|
20
|
+
import {
|
|
21
|
+
type Claims,
|
|
22
|
+
getCurrentUiState,
|
|
23
|
+
onUiStateChanged,
|
|
24
|
+
getCurrentClaims,
|
|
25
|
+
} from '../sdk/LiveVoiceState';
|
|
26
|
+
import { BrandingView } from './BrandingView';
|
|
27
|
+
import { ErrorView } from './ErrorView';
|
|
28
|
+
import { ReconnectingView } from './ReconnectingView';
|
|
28
29
|
|
|
29
30
|
import { PlayingState } from "../util/PlayingState";
|
|
30
31
|
|
|
31
|
-
import { useEffect, useState } from "react";
|
|
32
|
-
import { View, ActivityIndicator } from "react-native";
|
|
32
|
+
import { Fragment, useEffect, useState } from "react";
|
|
33
|
+
import { View, ActivityIndicator, Text, useColorScheme } from "react-native";
|
|
33
34
|
|
|
34
35
|
import { COLORS } from "../util/Colors";
|
|
35
|
-
import {
|
|
36
|
+
import { Translations } from "../util/Translations";
|
|
37
|
+
import { type Channel, type UiState } from "../util/UIState";
|
|
36
38
|
import { ChannelView } from "./ChannelView";
|
|
37
39
|
|
|
40
|
+
/** Per-cell helpers passed to {@link LiveVoiceViewProps.renderChannel}, mirroring the native SDKs. */
|
|
41
|
+
export interface ChannelCellHelpers {
|
|
42
|
+
/** Whether this is the last channel in the (filtered) list — e.g. to omit a trailing divider. */
|
|
43
|
+
isLastInList: boolean;
|
|
44
|
+
/** Toggle audio for this channel: starts it if stopped, stops it if playing. */
|
|
45
|
+
onAudioPress: () => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Renders a custom channel cell. See {@link LiveVoiceViewProps.renderChannel}. */
|
|
49
|
+
export type RenderChannel = (
|
|
50
|
+
channel: Channel,
|
|
51
|
+
helpers: ChannelCellHelpers,
|
|
52
|
+
) => React.ReactNode;
|
|
53
|
+
|
|
38
54
|
export interface LiveVoiceViewProps {
|
|
39
55
|
isDarkMode?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Return true for channels that should be displayed by the drop-in view.
|
|
58
|
+
*/
|
|
59
|
+
filter?: (channel: Channel) => boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Render a custom channel cell instead of the default one.
|
|
62
|
+
*
|
|
63
|
+
* Requires an API key that permits custom UI. If a `renderChannel` is provided but the joined
|
|
64
|
+
* event's key doesn't allow custom UI, the view shows the invalid-api-key error instead — the
|
|
65
|
+
* same gating the native SDKs apply. When omitted, the default cell is used.
|
|
66
|
+
*/
|
|
67
|
+
renderChannel?: RenderChannel;
|
|
40
68
|
}
|
|
41
69
|
|
|
42
|
-
|
|
70
|
+
function useLiveVoiceViewState(): {
|
|
71
|
+
claims: Claims | null;
|
|
72
|
+
uiState: UiState;
|
|
73
|
+
} {
|
|
43
74
|
const [uiState, setUiState] = useState<UiState>(() => getCurrentUiState());
|
|
75
|
+
const [claims, setClaims] = useState<Claims | null>(() =>
|
|
76
|
+
getCurrentUiState().type === 'ready' ? getCurrentClaims() : null,
|
|
77
|
+
);
|
|
44
78
|
|
|
45
79
|
useEffect(() => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
subscription = undefined;
|
|
80
|
+
// Claims belong to the current `ready` session. Read them fresh on every
|
|
81
|
+
// `ready` transition and clear them otherwise, so a stale value (e.g.
|
|
82
|
+
// `customUiAllowed` from a previously joined API key) can never outlive the
|
|
83
|
+
// session that produced it and keep the gate open after switching keys.
|
|
84
|
+
const apply = (nextUiState: UiState) => {
|
|
85
|
+
setUiState(nextUiState);
|
|
86
|
+
setClaims(nextUiState.type === 'ready' ? getCurrentClaims() : null);
|
|
54
87
|
};
|
|
55
|
-
}, []);
|
|
56
88
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
console.log(
|
|
61
|
-
"available subtitles changed! …" + JSON.stringify(data).slice(-20),
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
return () => {
|
|
65
|
-
subscription?.remove();
|
|
66
|
-
subscription = undefined;
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
89
|
+
const subscription = onUiStateChanged(apply);
|
|
90
|
+
|
|
91
|
+
apply(getCurrentUiState());
|
|
69
92
|
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
let subscription: { remove: () => void } | undefined = onSubtitlesChanged(
|
|
72
|
-
(data: [String]) => {
|
|
73
|
-
console.log(
|
|
74
|
-
"available subtitles changed! …" + JSON.stringify(data).slice(-20),
|
|
75
|
-
);
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
93
|
return () => {
|
|
79
|
-
subscription
|
|
80
|
-
subscription = undefined;
|
|
94
|
+
subscription.remove();
|
|
81
95
|
};
|
|
82
96
|
}, []);
|
|
83
97
|
|
|
84
|
-
|
|
98
|
+
return { uiState, claims };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const LiveVoiceView: React.FC<LiveVoiceViewProps> = ({
|
|
102
|
+
isDarkMode,
|
|
103
|
+
filter,
|
|
104
|
+
renderChannel,
|
|
105
|
+
}) => {
|
|
106
|
+
const systemDarkMode = useColorScheme() === "dark";
|
|
107
|
+
const dark = isDarkMode ?? systemDarkMode;
|
|
108
|
+
const { uiState, claims } = useLiveVoiceViewState();
|
|
85
109
|
|
|
86
110
|
switch (uiState.type) {
|
|
87
|
-
case "ready":
|
|
88
|
-
const backgroundColor =
|
|
89
|
-
const dividerColor =
|
|
111
|
+
case "ready": {
|
|
112
|
+
const backgroundColor = dark ? COLORS.cardBgDark : COLORS.cardBg;
|
|
113
|
+
const dividerColor = dark ? COLORS.dividerDark : COLORS.divider;
|
|
114
|
+
const visibleChannels =
|
|
115
|
+
filter == null ? uiState.channels : uiState.channels.filter(filter);
|
|
116
|
+
const customUiAllowed = claims?.customUiAllowed ?? false;
|
|
117
|
+
|
|
118
|
+
// A custom cell was provided but the joined event's key doesn't permit custom UI.
|
|
119
|
+
// Mirror the native SDKs and surface the invalid-api-key error instead of rendering it.
|
|
120
|
+
if (renderChannel != null && !customUiAllowed) {
|
|
121
|
+
return (
|
|
122
|
+
<ErrorView
|
|
123
|
+
state={{
|
|
124
|
+
type: "error",
|
|
125
|
+
message: Translations.sdkErrorInvalidApiKey(),
|
|
126
|
+
canBeRetried: false,
|
|
127
|
+
}}
|
|
128
|
+
isDarkMode={dark}
|
|
129
|
+
onPress={() => {}}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const showBranding = claims === null || !claims.hideBranding;
|
|
135
|
+
const emptyText =
|
|
136
|
+
uiState.channels.length === 0 || filter == null
|
|
137
|
+
? Translations.noChannels()
|
|
138
|
+
: Translations.sdkNoMatchingChannels();
|
|
139
|
+
|
|
140
|
+
const emptyView = (
|
|
141
|
+
<View style={{ paddingVertical: 30, paddingHorizontal: 16 }}>
|
|
142
|
+
<Text
|
|
143
|
+
style={{
|
|
144
|
+
fontSize: 14,
|
|
145
|
+
fontWeight: "500",
|
|
146
|
+
textAlign: "center",
|
|
147
|
+
color: dark ? COLORS.white : COLORS.black,
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
{emptyText}
|
|
151
|
+
</Text>
|
|
152
|
+
</View>
|
|
153
|
+
);
|
|
90
154
|
|
|
155
|
+
// Custom cells get full control (no card chrome / dividers), like the native SDKs.
|
|
156
|
+
if (renderChannel != null) {
|
|
157
|
+
return (
|
|
158
|
+
<View style={{ width: "100%" }}>
|
|
159
|
+
{visibleChannels.length === 0
|
|
160
|
+
? emptyView
|
|
161
|
+
: visibleChannels.map((channel: Channel, index: number) => (
|
|
162
|
+
<Fragment key={channel.id}>
|
|
163
|
+
{renderChannel(channel, {
|
|
164
|
+
isLastInList: index === visibleChannels.length - 1,
|
|
165
|
+
onAudioPress: () =>
|
|
166
|
+
channel.playingState === PlayingState.PLAYING
|
|
167
|
+
? stopChannel()
|
|
168
|
+
: startChannel(channel.id),
|
|
169
|
+
})}
|
|
170
|
+
</Fragment>
|
|
171
|
+
))}
|
|
172
|
+
{showBranding && <BrandingView isDarkMode={dark} />}
|
|
173
|
+
</View>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Default cells.
|
|
91
178
|
return (
|
|
92
179
|
<View style={{ width: "100%" }}>
|
|
93
180
|
<View
|
|
@@ -97,44 +184,46 @@ export const LiveVoiceView: React.FC<LiveVoiceViewProps> = ({ isDarkMode }) => {
|
|
|
97
184
|
overflow: "hidden",
|
|
98
185
|
}}
|
|
99
186
|
>
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
channel.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
style={{
|
|
120
|
-
height: 1,
|
|
121
|
-
backgroundColor: dividerColor,
|
|
122
|
-
marginHorizontal: 10,
|
|
123
|
-
}}
|
|
187
|
+
{visibleChannels.length === 0 ? (
|
|
188
|
+
emptyView
|
|
189
|
+
) : (
|
|
190
|
+
visibleChannels.map((channel: Channel, index: number) => (
|
|
191
|
+
<View key={channel.id}>
|
|
192
|
+
<ChannelView
|
|
193
|
+
playingState={channel.playingState}
|
|
194
|
+
isDarkMode={dark}
|
|
195
|
+
muted={channel.isAudioMuted}
|
|
196
|
+
isOnline={channel.isOnline}
|
|
197
|
+
hasAudio={channel.hasAudio}
|
|
198
|
+
hasSubtitles={channel.hasSubtitles}
|
|
199
|
+
channelName={channel.name}
|
|
200
|
+
onAudioPress={() =>
|
|
201
|
+
channel.playingState === PlayingState.PLAYING
|
|
202
|
+
? stopChannel()
|
|
203
|
+
: startChannel(channel.id)
|
|
204
|
+
}
|
|
205
|
+
onSubtitlesPress={() => startSubtitles(channel.id)}
|
|
124
206
|
/>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
207
|
+
{index < visibleChannels.length - 1 && (
|
|
208
|
+
<View
|
|
209
|
+
style={{
|
|
210
|
+
height: 1,
|
|
211
|
+
backgroundColor: dividerColor,
|
|
212
|
+
marginHorizontal: 10,
|
|
213
|
+
}}
|
|
214
|
+
/>
|
|
215
|
+
)}
|
|
216
|
+
</View>
|
|
217
|
+
))
|
|
218
|
+
)}
|
|
219
|
+
{showBranding && <BrandingView isDarkMode={dark} />}
|
|
128
220
|
</View>
|
|
129
|
-
|
|
130
|
-
{(claims === null || !claims.hideBranding) && (
|
|
131
|
-
<BrandingView isDarkMode={isDarkMode} />
|
|
132
|
-
)}
|
|
133
221
|
</View>
|
|
134
222
|
);
|
|
223
|
+
}
|
|
135
224
|
|
|
136
225
|
case "loading":
|
|
137
|
-
const loadingBackgroundColor =
|
|
226
|
+
const loadingBackgroundColor = dark
|
|
138
227
|
? COLORS.cardBgDark
|
|
139
228
|
: COLORS.cardBg;
|
|
140
229
|
|
|
@@ -157,6 +246,7 @@ export const LiveVoiceView: React.FC<LiveVoiceViewProps> = ({ isDarkMode }) => {
|
|
|
157
246
|
return (
|
|
158
247
|
<ErrorView
|
|
159
248
|
state={uiState}
|
|
249
|
+
isDarkMode={dark}
|
|
160
250
|
onPress={() => {
|
|
161
251
|
reconnect();
|
|
162
252
|
}}
|
|
@@ -167,6 +257,7 @@ export const LiveVoiceView: React.FC<LiveVoiceViewProps> = ({ isDarkMode }) => {
|
|
|
167
257
|
return (
|
|
168
258
|
<ReconnectingView
|
|
169
259
|
state={uiState}
|
|
260
|
+
isDarkMode={dark}
|
|
170
261
|
onPress={() => {
|
|
171
262
|
reconnect();
|
|
172
263
|
}}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
//
|
|
3
|
+
// This source file is part of the LiveVoice SDK project
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) LiveVoice GmbH
|
|
6
|
+
// Licensed under the MIT license
|
|
7
|
+
//
|
|
8
|
+
// See LICENSE for license information
|
|
9
|
+
//
|
|
10
|
+
// SPDX-License-Identifier: MIT
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
11
13
|
|
|
12
14
|
import { COLORS } from "../util/Colors";
|
|
13
15
|
import {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
//
|
|
3
|
+
// This source file is part of the LiveVoice SDK project
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) LiveVoice GmbH
|
|
6
|
+
// Licensed under the MIT license
|
|
7
|
+
//
|
|
8
|
+
// See LICENSE for license information
|
|
9
|
+
//
|
|
10
|
+
// SPDX-License-Identifier: MIT
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
11
13
|
|
|
12
14
|
import React, { useEffect } from 'react';
|
|
13
15
|
import { View, Text, useColorScheme, StyleSheet, TouchableOpacity, ActivityIndicator } from 'react-native';
|
|
@@ -32,12 +34,10 @@ export const ReconnectingView: React.FC<ReconnectingProps> = (props) => {
|
|
|
32
34
|
//updated the countdown every second!
|
|
33
35
|
useEffect(() => {
|
|
34
36
|
const newValue = calculateSecondsUntilRetry(reconnectingState)
|
|
35
|
-
console.log('Updated seconds' + newValue)
|
|
36
37
|
setSecUntilRetry(newValue);
|
|
37
38
|
|
|
38
39
|
const interval = setInterval(() => {
|
|
39
40
|
const newValue = calculateSecondsUntilRetry(reconnectingState)
|
|
40
|
-
console.log('Updated seconds' + newValue)
|
|
41
41
|
setSecUntilRetry(newValue);
|
|
42
42
|
}, 1000);
|
|
43
43
|
|
|
@@ -92,7 +92,14 @@ export const ReconnectingView: React.FC<ReconnectingProps> = (props) => {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
function calculateSecondsUntilRetry(reconnectingState: Reconnecting): number {
|
|
95
|
-
|
|
95
|
+
if (reconnectingState.state.type !== 'awaitingRetry') {
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return Math.max(
|
|
100
|
+
0,
|
|
101
|
+
(reconnectingState.state.retryAt.getTime() / 1000) - (Date.now() / 1000),
|
|
102
|
+
);
|
|
96
103
|
}
|
|
97
104
|
|
|
98
105
|
const styles = StyleSheet.create({
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
//
|
|
3
|
+
// This source file is part of the LiveVoice SDK project
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) LiveVoice GmbH
|
|
6
|
+
// Licensed under the MIT license
|
|
7
|
+
//
|
|
8
|
+
// See LICENSE for license information
|
|
9
|
+
//
|
|
10
|
+
// SPDX-License-Identifier: MIT
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
11
13
|
|
|
12
14
|
import React from 'react';
|
|
13
15
|
import { View, Text, useColorScheme, StyleSheet } from 'react-native';
|
package/src/components/index.tsx
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
//
|
|
3
|
+
// This source file is part of the LiveVoice SDK project
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) LiveVoice GmbH
|
|
6
|
+
// Licensed under the MIT license
|
|
7
|
+
//
|
|
8
|
+
// See LICENSE for license information
|
|
9
|
+
//
|
|
10
|
+
// SPDX-License-Identifier: MIT
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
11
13
|
|
|
12
14
|
export * from './AudioOutputSwitchView';
|
|
13
15
|
export * from './BrandingView';
|