@equos/react 3.0.2-rc.11 → 3.0.2-rc.12
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.
|
@@ -7,8 +7,8 @@ const cn_1 = require("../utils/cn");
|
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const livekit_client_1 = require("livekit-client");
|
|
9
9
|
const copy_utils_1 = require("../utils/copy.utils");
|
|
10
|
+
const WAIT_FOR_CHARACTER_TO_JOIN = 20;
|
|
10
11
|
function EquosCharacterTile({ identity, name, locale = copy_utils_1.EquosLocale.EN, className, startedAt, maxSeconds, recoveryTimeInSeconds = 3, showTimeLeft = true, onShouldLeave, }) {
|
|
11
|
-
const waitForCharacterToJoin = 20;
|
|
12
12
|
const [joined, setJoined] = (0, react_1.useState)(false);
|
|
13
13
|
const [leftTimeout, setLeftTimeout] = (0, react_1.useState)(null);
|
|
14
14
|
const [remainingTime, setRemainingTime] = (0, react_1.useState)(null);
|
|
@@ -30,7 +30,7 @@ function EquosCharacterTile({ identity, name, locale = copy_utils_1.EquosLocale.
|
|
|
30
30
|
};
|
|
31
31
|
}, [identity, participants]);
|
|
32
32
|
const hasTroubleJoining = (0, react_1.useMemo)(() => {
|
|
33
|
-
return !joined && duration >
|
|
33
|
+
return !joined && duration > WAIT_FOR_CHARACTER_TO_JOIN - 10;
|
|
34
34
|
}, [joined, duration]);
|
|
35
35
|
const joiningCopy = (0, react_1.useMemo)(() => {
|
|
36
36
|
return copy_utils_1.CopyUtils.joiningCopy(locale, name);
|
|
@@ -39,17 +39,17 @@ function EquosCharacterTile({ identity, name, locale = copy_utils_1.EquosLocale.
|
|
|
39
39
|
return copy_utils_1.CopyUtils.notJoiningCopy(locale, name);
|
|
40
40
|
}, [name, locale]);
|
|
41
41
|
const endingConversationCopy = (0, react_1.useMemo)(() => {
|
|
42
|
-
return copy_utils_1.CopyUtils.endingConversationCopy(locale, Math.max(
|
|
43
|
-
}, [duration, locale,
|
|
42
|
+
return copy_utils_1.CopyUtils.endingConversationCopy(locale, Math.max(WAIT_FOR_CHARACTER_TO_JOIN - duration, 0));
|
|
43
|
+
}, [duration, locale, WAIT_FOR_CHARACTER_TO_JOIN]);
|
|
44
44
|
// Detect if we should leave the conversation because the character is not joining...
|
|
45
45
|
(0, react_1.useEffect)(() => {
|
|
46
46
|
if (!onShouldLeave)
|
|
47
47
|
return;
|
|
48
|
-
if (!joined && duration >
|
|
49
|
-
console.log('calling on should leave...');
|
|
48
|
+
if (!joined && duration > WAIT_FOR_CHARACTER_TO_JOIN) {
|
|
49
|
+
console.log('calling on should leave...', joined, duration, WAIT_FOR_CHARACTER_TO_JOIN, onShouldLeave);
|
|
50
50
|
onShouldLeave();
|
|
51
51
|
}
|
|
52
|
-
}, [joined, duration,
|
|
52
|
+
}, [joined, duration, WAIT_FOR_CHARACTER_TO_JOIN, onShouldLeave]);
|
|
53
53
|
(0, react_1.useEffect)(() => {
|
|
54
54
|
const i = setInterval(() => {
|
|
55
55
|
const elapsedTime = new Date().getTime() - startedAt.getTime();
|
|
@@ -64,7 +64,6 @@ function EquosCharacterTile({ identity, name, locale = copy_utils_1.EquosLocale.
|
|
|
64
64
|
if (!trackRef && !leftTimeout && onShouldLeave) {
|
|
65
65
|
setLeftTimeout(setTimeout(() => {
|
|
66
66
|
onShouldLeave?.();
|
|
67
|
-
console.log('calling on should leave... (timeout)');
|
|
68
67
|
}, recoveryTimeInSeconds * 1000));
|
|
69
68
|
}
|
|
70
69
|
}
|