@magmamath/students-features 1.3.23-rc.12 → 1.3.23-rc.13
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/dist/commonjs/features/voice/playing/components/VoiceTranscription.js +6 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.js +46 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +0 -13
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscription.js +6 -0
- package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.js +41 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +0 -13
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts +16 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts +16 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/voice/playing/components/VoiceTranscription.tsx +7 -0
- package/src/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.ts +57 -0
- package/src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts +0 -15
|
@@ -17,6 +17,7 @@ var _supportedLanguages = require("../../../translation/providers/google/support
|
|
|
17
17
|
var _i18n = require("../../../../i18n/i18n.js");
|
|
18
18
|
var _useVoiceTranscriptionEffects = require("../hooks/useVoiceTranscriptionEffects.js");
|
|
19
19
|
var _useVoiceTranscriptionAutoTranslate = require("../hooks/useVoiceTranscriptionAutoTranslate.js");
|
|
20
|
+
var _useVoiceTranscriptionAutoExpand = require("../hooks/useVoiceTranscriptionAutoExpand.js");
|
|
20
21
|
var _VoiceTranscriptContent = require("./VoiceTranscriptContent.js");
|
|
21
22
|
var _VoiceTranscriptionCollapsible = require("./VoiceTranscriptionCollapsible.js");
|
|
22
23
|
var _VoiceTranscriptionHeaderActions = require("./VoiceTranscriptionHeaderActions.js");
|
|
@@ -65,6 +66,11 @@ const VoiceTranscription = ({
|
|
|
65
66
|
activeAttempt,
|
|
66
67
|
problemId
|
|
67
68
|
});
|
|
69
|
+
(0, _useVoiceTranscriptionAutoExpand.useVoiceTranscriptionAutoExpand)({
|
|
70
|
+
model,
|
|
71
|
+
activeAttempt,
|
|
72
|
+
targetLanguage: i18n.language
|
|
73
|
+
});
|
|
68
74
|
(0, _react.useEffect)(() => {
|
|
69
75
|
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
70
76
|
model.translation.translate({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeUi","require","_effectorReact","_react","_interopRequireWildcard","_reactI18next","_reactNative","_reactNativeReanimated","_interopRequireDefault","_constants","_helpers","_types","_supportedLanguages","_i18n","_useVoiceTranscriptionEffects","_useVoiceTranscriptionAutoTranslate","_VoiceTranscriptContent","_VoiceTranscriptionCollapsible","_VoiceTranscriptionHeaderActions","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","VoiceTranscriptionVariant","SMALL","useText","i18n","useTranslation","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","useUnit","$playerState","loader","loadAllTranscripts","pending","translation","$isActive","$translations","translate","activeAttempt","getActiveAttempt","isLargeVariant","LARGE","answersKey","useMemo","map","_id","audioFileId","join","useVoiceTranscriptionEffects","hasActiveAudio","undefined","activeTranscript","getTranscript","hasTranscriptText","NO_AUDIO_BE_MESSAGE","isActiveTranscriptLoading","transcriptLanguage","getTranscriptLanguage","isSourceSameAsTarget","resolveGoogleLanguageCode","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","useVoiceTranscriptionAutoTranslate","translationModel","
|
|
1
|
+
{"version":3,"names":["_reactNativeUi","require","_effectorReact","_react","_interopRequireWildcard","_reactI18next","_reactNative","_reactNativeReanimated","_interopRequireDefault","_constants","_helpers","_types","_supportedLanguages","_i18n","_useVoiceTranscriptionEffects","_useVoiceTranscriptionAutoTranslate","_useVoiceTranscriptionAutoExpand","_VoiceTranscriptContent","_VoiceTranscriptionCollapsible","_VoiceTranscriptionHeaderActions","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","VoiceTranscriptionVariant","SMALL","useText","i18n","useTranslation","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","useUnit","$playerState","loader","loadAllTranscripts","pending","translation","$isActive","$translations","translate","activeAttempt","getActiveAttempt","isLargeVariant","LARGE","answersKey","useMemo","map","_id","audioFileId","join","useVoiceTranscriptionEffects","hasActiveAudio","undefined","activeTranscript","getTranscript","hasTranscriptText","NO_AUDIO_BE_MESSAGE","isActiveTranscriptLoading","transcriptLanguage","getTranscriptLanguage","isSourceSameAsTarget","resolveGoogleLanguageCode","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","useVoiceTranscriptionAutoTranslate","translationModel","useVoiceTranscriptionAutoExpand","targetLanguage","useEffect","attemptNumber","handlePlayPress","useCallback","setActive","togglePlayPause","handleTranslationToggle","toggle","jsxs","View","styles","container","largeContainer","children","header","jsx","Typography","title","VoiceTranscriptionHeaderActions","onPlayPress","onTranslationPress","VoiceTranscriptContent","text","isLoading","VoiceTranscriptionCollapsible","dropdown","exports","StyleSheet","create","position","top","left","width","maxHeight","minHeight","padding","boxShadow","borderRadius","backgroundColor","COLORS","NEUTRAL_1","overflow","height","flexDirection","justifyContent","alignItems","marginBottom","color","NEUTRAL_9","marginLeft"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/components/VoiceTranscription.tsx"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,mBAAA,GAAAX,OAAA;AACA,IAAAY,KAAA,GAAAZ,OAAA;AACA,IAAAa,6BAAA,GAAAb,OAAA;AACA,IAAAc,mCAAA,GAAAd,OAAA;AACA,IAAAe,gCAAA,GAAAf,OAAA;AAEA,IAAAgB,uBAAA,GAAAhB,OAAA;AACA,IAAAiB,8BAAA,GAAAjB,OAAA;AACA,IAAAkB,gCAAA,GAAAlB,OAAA;AAAmF,IAAAmB,WAAA,GAAAnB,OAAA;AAAA,SAAAO,uBA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AAC;IACfJ,MAAM,EAAE;EACV,CAAC;EACDzB,KAAK,EAAE;IACL8B,KAAK,EAAER,qBAAM,CAACS,SAAS;IACvBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useVoiceTranscriptionAutoExpand = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _effectorReact = require("effector-react");
|
|
9
|
+
var _constants = require("../../constants.js");
|
|
10
|
+
var _supportedLanguages = require("../../../translation/providers/google/supportedLanguages.js");
|
|
11
|
+
/**
|
|
12
|
+
* Auto-expands the transcription dropdown based on content readiness:
|
|
13
|
+
* - Stays collapsed during transcript loading or for drawing-only attempts.
|
|
14
|
+
* - When source language matches target, expands as soon as a real transcript is loaded.
|
|
15
|
+
* - When source differs from target, waits until the translation for that attempt is
|
|
16
|
+
* available, then expands.
|
|
17
|
+
*/
|
|
18
|
+
const useVoiceTranscriptionAutoExpand = ({
|
|
19
|
+
model,
|
|
20
|
+
activeAttempt,
|
|
21
|
+
targetLanguage
|
|
22
|
+
}) => {
|
|
23
|
+
const [transcriptsLoaded, translations] = (0, _effectorReact.useUnit)([model.loader.$transcriptsLoaded, model.translation.$translations]);
|
|
24
|
+
(0, _react.useEffect)(() => {
|
|
25
|
+
if (activeAttempt === null) return;
|
|
26
|
+
if (!transcriptsLoaded) {
|
|
27
|
+
model.dropdown.setExpanded(false);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const transcript = model.loader.getTranscript(activeAttempt);
|
|
31
|
+
const hasRealTranscript = !!transcript && transcript !== _constants.NO_AUDIO_BE_MESSAGE;
|
|
32
|
+
if (!hasRealTranscript) {
|
|
33
|
+
model.dropdown.setExpanded(false);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const sourceLanguage = model.loader.getTranscriptLanguage(activeAttempt);
|
|
37
|
+
const needsTranslation = !!sourceLanguage && (0, _supportedLanguages.resolveGoogleLanguageCode)(sourceLanguage) !== (0, _supportedLanguages.resolveGoogleLanguageCode)(targetLanguage);
|
|
38
|
+
if (needsTranslation) {
|
|
39
|
+
model.dropdown.setExpanded(!!translations[activeAttempt]);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
model.dropdown.setExpanded(true);
|
|
43
|
+
}, [activeAttempt, transcriptsLoaded, translations, targetLanguage, model]);
|
|
44
|
+
};
|
|
45
|
+
exports.useVoiceTranscriptionAutoExpand = useVoiceTranscriptionAutoExpand;
|
|
46
|
+
//# sourceMappingURL=useVoiceTranscriptionAutoExpand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_effectorReact","_constants","_supportedLanguages","useVoiceTranscriptionAutoExpand","model","activeAttempt","targetLanguage","transcriptsLoaded","translations","useUnit","loader","$transcriptsLoaded","translation","$translations","useEffect","dropdown","setExpanded","transcript","getTranscript","hasRealTranscript","NO_AUDIO_BE_MESSAGE","sourceLanguage","getTranscriptLanguage","needsTranslation","resolveGoogleLanguageCode","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,mBAAA,GAAAH,OAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,+BAA+B,GAAGA,CAAC;EAC9CC,KAAK;EACLC,aAAa;EACbC;AACM,CAAC,KAAK;EACZ,MAAM,CAACC,iBAAiB,EAAEC,YAAY,CAAC,GAAG,IAAAC,sBAAO,EAAC,CAChDL,KAAK,CAACM,MAAM,CAACC,kBAAkB,EAC/BP,KAAK,CAACQ,WAAW,CAACC,aAAa,CAChC,CAAC;EAEF,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIT,aAAa,KAAK,IAAI,EAAE;IAE5B,IAAI,CAACE,iBAAiB,EAAE;MACtBH,KAAK,CAACW,QAAQ,CAACC,WAAW,CAAC,KAAK,CAAC;MACjC;IACF;IAEA,MAAMC,UAAU,GAAGb,KAAK,CAACM,MAAM,CAACQ,aAAa,CAACb,aAAa,CAAC;IAC5D,MAAMc,iBAAiB,GAAG,CAAC,CAACF,UAAU,IAAIA,UAAU,KAAKG,8BAAmB;IAC5E,IAAI,CAACD,iBAAiB,EAAE;MACtBf,KAAK,CAACW,QAAQ,CAACC,WAAW,CAAC,KAAK,CAAC;MACjC;IACF;IAEA,MAAMK,cAAc,GAAGjB,KAAK,CAACM,MAAM,CAACY,qBAAqB,CAACjB,aAAa,CAAC;IACxE,MAAMkB,gBAAgB,GACpB,CAAC,CAACF,cAAc,IAChB,IAAAG,6CAAyB,EAACH,cAAc,CAAC,KAAK,IAAAG,6CAAyB,EAAClB,cAAc,CAAC;IAEzF,IAAIiB,gBAAgB,EAAE;MACpBnB,KAAK,CAACW,QAAQ,CAACC,WAAW,CAAC,CAAC,CAACR,YAAY,CAACH,aAAa,CAAC,CAAC;MACzD;IACF;IAEAD,KAAK,CAACW,QAAQ,CAACC,WAAW,CAAC,IAAI,CAAC;EAClC,CAAC,EAAE,CAACX,aAAa,EAAEE,iBAAiB,EAAEC,YAAY,EAAEF,cAAc,EAAEF,KAAK,CAAC,CAAC;AAC7E,CAAC;AAAAqB,OAAA,CAAAtB,+BAAA,GAAAA,+BAAA","ignoreList":[]}
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useVoiceTranscriptionEffects = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var _effectorReact = require("effector-react");
|
|
9
|
-
var _constants = require("../../constants.js");
|
|
10
8
|
const useVoiceTranscriptionEffects = ({
|
|
11
9
|
model,
|
|
12
10
|
answers,
|
|
@@ -23,17 +21,6 @@ const useVoiceTranscriptionEffects = ({
|
|
|
23
21
|
(0, _react.useEffect)(() => {
|
|
24
22
|
model.resetPlayer();
|
|
25
23
|
}, [problemId]);
|
|
26
|
-
const transcriptsLoaded = (0, _effectorReact.useUnit)(model.loader.$transcriptsLoaded);
|
|
27
|
-
(0, _react.useEffect)(() => {
|
|
28
|
-
if (activeAttempt === null) return;
|
|
29
|
-
if (!transcriptsLoaded) {
|
|
30
|
-
model.dropdown.setExpanded(false);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const transcript = model.loader.getTranscript(activeAttempt);
|
|
34
|
-
const hasRealTranscript = !!transcript && transcript !== _constants.NO_AUDIO_BE_MESSAGE;
|
|
35
|
-
model.dropdown.setExpanded(hasRealTranscript);
|
|
36
|
-
}, [activeAttempt, transcriptsLoaded, model]);
|
|
37
24
|
(0, _react.useEffect)(() => {
|
|
38
25
|
if (answersRef.current.some(answer => answer.audioFileId)) {
|
|
39
26
|
model.initializeWithAudios(answersRef.current);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","
|
|
1
|
+
{"version":3,"names":["_react","require","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","useRef","current","useEffect","reinitializePlayer","cleanup","resetPlayer","some","answer","audioFileId","initializeWithAudios","loader","loadAllTranscripts","stopAudio","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAYO,MAAMC,4BAA4B,GAAGA,CAAC;EAC3CC,KAAK;EACLC,OAAO;EACPC,UAAU;EACVC,SAAS;EACTC;AACM,CAAC,KAAK;EACZ,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAACL,OAAO,CAAC;EAClCI,UAAU,CAACE,OAAO,GAAGN,OAAO;EAE5B,IAAAO,gBAAS,EAAC,MAAM;IACdR,KAAK,CAACS,kBAAkB,CAAC,CAAC;IAC1B,OAAO,MAAMT,KAAK,CAACU,OAAO,CAAC,CAAC;EAC9B,CAAC,EAAE,CAACV,KAAK,CAAC,CAAC;EAEX,IAAAQ,gBAAS,EAAC,MAAM;IACdR,KAAK,CAACW,WAAW,CAAC,CAAC;EACrB,CAAC,EAAE,CAACR,SAAS,CAAC,CAAC;EAEf,IAAAK,gBAAS,EAAC,MAAM;IACd,IAAIH,UAAU,CAACE,OAAO,CAACK,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,WAAW,CAAC,EAAE;MAC3Dd,KAAK,CAACe,oBAAoB,CAACV,UAAU,CAACE,OAAO,CAAC;MAC9CP,KAAK,CAACgB,MAAM,CAACC,kBAAkB,CAAC,CAAC;IACnC;EACF,CAAC,EAAE,CAACjB,KAAK,EAAEE,UAAU,CAAC,CAAC;EAEvB,IAAAM,gBAAS,EAAC,MAAM;IACdR,KAAK,CAACkB,SAAS,CAAC,CAAC;EACnB,CAAC,EAAE,CAACd,aAAa,CAAC,CAAC;AACrB,CAAC;AAAAe,OAAA,CAAApB,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -13,6 +13,7 @@ import { resolveGoogleLanguageCode } from "../../../translation/providers/google
|
|
|
13
13
|
import { useText } from "../../../../i18n/i18n.js";
|
|
14
14
|
import { useVoiceTranscriptionEffects } from "../hooks/useVoiceTranscriptionEffects.js";
|
|
15
15
|
import { useVoiceTranscriptionAutoTranslate } from "../hooks/useVoiceTranscriptionAutoTranslate.js";
|
|
16
|
+
import { useVoiceTranscriptionAutoExpand } from "../hooks/useVoiceTranscriptionAutoExpand.js";
|
|
16
17
|
import { VoiceTranscriptContent } from "./VoiceTranscriptContent.js";
|
|
17
18
|
import { VoiceTranscriptionCollapsible } from "./VoiceTranscriptionCollapsible.js";
|
|
18
19
|
import { VoiceTranscriptionHeaderActions } from "./VoiceTranscriptionHeaderActions.js";
|
|
@@ -58,6 +59,11 @@ export const VoiceTranscription = ({
|
|
|
58
59
|
activeAttempt,
|
|
59
60
|
problemId
|
|
60
61
|
});
|
|
62
|
+
useVoiceTranscriptionAutoExpand({
|
|
63
|
+
model,
|
|
64
|
+
activeAttempt,
|
|
65
|
+
targetLanguage: i18n.language
|
|
66
|
+
});
|
|
61
67
|
useEffect(() => {
|
|
62
68
|
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
63
69
|
model.translation.translate({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Typography","COLORS","useUnit","React","useCallback","useEffect","useMemo","useTranslation","StyleSheet","View","Animated","NO_AUDIO_BE_MESSAGE","getActiveAttempt","VoiceTranscriptionVariant","resolveGoogleLanguageCode","useText","useVoiceTranscriptionEffects","useVoiceTranscriptionAutoTranslate","VoiceTranscriptContent","VoiceTranscriptionCollapsible","VoiceTranscriptionHeaderActions","jsx","_jsx","jsxs","_jsxs","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","SMALL","t","i18n","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","$playerState","loader","loadAllTranscripts","pending","translation","$isActive","$translations","translate","activeAttempt","isLargeVariant","LARGE","answersKey","map","a","_id","audioFileId","join","hasActiveAudio","undefined","activeTranscript","getTranscript","hasTranscriptText","isActiveTranscriptLoading","transcriptLanguage","getTranscriptLanguage","isSourceSameAsTarget","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","translationModel","
|
|
1
|
+
{"version":3,"names":["Typography","COLORS","useUnit","React","useCallback","useEffect","useMemo","useTranslation","StyleSheet","View","Animated","NO_AUDIO_BE_MESSAGE","getActiveAttempt","VoiceTranscriptionVariant","resolveGoogleLanguageCode","useText","useVoiceTranscriptionEffects","useVoiceTranscriptionAutoTranslate","useVoiceTranscriptionAutoExpand","VoiceTranscriptContent","VoiceTranscriptionCollapsible","VoiceTranscriptionHeaderActions","jsx","_jsx","jsxs","_jsxs","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","SMALL","t","i18n","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","$playerState","loader","loadAllTranscripts","pending","translation","$isActive","$translations","translate","activeAttempt","isLargeVariant","LARGE","answersKey","map","a","_id","audioFileId","join","hasActiveAudio","undefined","activeTranscript","getTranscript","hasTranscriptText","isActiveTranscriptLoading","transcriptLanguage","getTranscriptLanguage","isSourceSameAsTarget","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","translationModel","targetLanguage","attemptNumber","handlePlayPress","setActive","togglePlayPause","handleTranslationToggle","toggle","styles","container","largeContainer","children","header","title","onPlayPress","onTranslationPress","text","isLoading","dropdown","create","position","top","left","width","maxHeight","minHeight","padding","boxShadow","borderRadius","backgroundColor","NEUTRAL_1","overflow","height","flexDirection","justifyContent","alignItems","marginBottom","color","NEUTRAL_9","marginLeft"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/components/VoiceTranscription.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,MAAM,QAAQ,4BAA4B;AAC/D,SAASC,OAAO,QAAQ,gBAAgB;AACxC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC9D,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAAoBC,UAAU,EAAEC,IAAI,QAAmB,cAAc;AACrE,OAAOC,QAAQ,MAAM,yBAAyB;AAC9C,SAASC,mBAAmB,QAAQ,oBAAiB;AACrD,SAASC,gBAAgB,QAAQ,kBAAe;AAChD,SAAsBC,yBAAyB,QAAQ,gBAAa;AACpE,SAASC,yBAAyB,QAAQ,6DAA0D;AACpG,SAASC,OAAO,QAAQ,0BAAuB;AAC/C,SAASC,4BAA4B,QAAQ,0CAAuC;AACpF,SAASC,kCAAkC,QAAQ,gDAA6C;AAChG,SAASC,+BAA+B,QAAQ,6CAA0C;AAE1F,SAASC,sBAAsB,QAAQ,6BAA0B;AACjE,SAASC,6BAA6B,QAAQ,oCAAiC;AAC/E,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+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { useUnit } from 'effector-react';
|
|
5
|
+
import { NO_AUDIO_BE_MESSAGE } from "../../constants.js";
|
|
6
|
+
import { resolveGoogleLanguageCode } from "../../../translation/providers/google/supportedLanguages.js";
|
|
7
|
+
/**
|
|
8
|
+
* Auto-expands the transcription dropdown based on content readiness:
|
|
9
|
+
* - Stays collapsed during transcript loading or for drawing-only attempts.
|
|
10
|
+
* - When source language matches target, expands as soon as a real transcript is loaded.
|
|
11
|
+
* - When source differs from target, waits until the translation for that attempt is
|
|
12
|
+
* available, then expands.
|
|
13
|
+
*/
|
|
14
|
+
export const useVoiceTranscriptionAutoExpand = ({
|
|
15
|
+
model,
|
|
16
|
+
activeAttempt,
|
|
17
|
+
targetLanguage
|
|
18
|
+
}) => {
|
|
19
|
+
const [transcriptsLoaded, translations] = useUnit([model.loader.$transcriptsLoaded, model.translation.$translations]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (activeAttempt === null) return;
|
|
22
|
+
if (!transcriptsLoaded) {
|
|
23
|
+
model.dropdown.setExpanded(false);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const transcript = model.loader.getTranscript(activeAttempt);
|
|
27
|
+
const hasRealTranscript = !!transcript && transcript !== NO_AUDIO_BE_MESSAGE;
|
|
28
|
+
if (!hasRealTranscript) {
|
|
29
|
+
model.dropdown.setExpanded(false);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const sourceLanguage = model.loader.getTranscriptLanguage(activeAttempt);
|
|
33
|
+
const needsTranslation = !!sourceLanguage && resolveGoogleLanguageCode(sourceLanguage) !== resolveGoogleLanguageCode(targetLanguage);
|
|
34
|
+
if (needsTranslation) {
|
|
35
|
+
model.dropdown.setExpanded(!!translations[activeAttempt]);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
model.dropdown.setExpanded(true);
|
|
39
|
+
}, [activeAttempt, transcriptsLoaded, translations, targetLanguage, model]);
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=useVoiceTranscriptionAutoExpand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useUnit","NO_AUDIO_BE_MESSAGE","resolveGoogleLanguageCode","useVoiceTranscriptionAutoExpand","model","activeAttempt","targetLanguage","transcriptsLoaded","translations","loader","$transcriptsLoaded","translation","$translations","dropdown","setExpanded","transcript","getTranscript","hasRealTranscript","sourceLanguage","getTranscriptLanguage","needsTranslation"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,OAAO,QAAQ,gBAAgB;AACxC,SAASC,mBAAmB,QAAQ,oBAAiB;AAErD,SAASC,yBAAyB,QAAQ,6DAA0D;AAQpG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,+BAA+B,GAAGA,CAAC;EAC9CC,KAAK;EACLC,aAAa;EACbC;AACM,CAAC,KAAK;EACZ,MAAM,CAACC,iBAAiB,EAAEC,YAAY,CAAC,GAAGR,OAAO,CAAC,CAChDI,KAAK,CAACK,MAAM,CAACC,kBAAkB,EAC/BN,KAAK,CAACO,WAAW,CAACC,aAAa,CAChC,CAAC;EAEFb,SAAS,CAAC,MAAM;IACd,IAAIM,aAAa,KAAK,IAAI,EAAE;IAE5B,IAAI,CAACE,iBAAiB,EAAE;MACtBH,KAAK,CAACS,QAAQ,CAACC,WAAW,CAAC,KAAK,CAAC;MACjC;IACF;IAEA,MAAMC,UAAU,GAAGX,KAAK,CAACK,MAAM,CAACO,aAAa,CAACX,aAAa,CAAC;IAC5D,MAAMY,iBAAiB,GAAG,CAAC,CAACF,UAAU,IAAIA,UAAU,KAAKd,mBAAmB;IAC5E,IAAI,CAACgB,iBAAiB,EAAE;MACtBb,KAAK,CAACS,QAAQ,CAACC,WAAW,CAAC,KAAK,CAAC;MACjC;IACF;IAEA,MAAMI,cAAc,GAAGd,KAAK,CAACK,MAAM,CAACU,qBAAqB,CAACd,aAAa,CAAC;IACxE,MAAMe,gBAAgB,GACpB,CAAC,CAACF,cAAc,IAChBhB,yBAAyB,CAACgB,cAAc,CAAC,KAAKhB,yBAAyB,CAACI,cAAc,CAAC;IAEzF,IAAIc,gBAAgB,EAAE;MACpBhB,KAAK,CAACS,QAAQ,CAACC,WAAW,CAAC,CAAC,CAACN,YAAY,CAACH,aAAa,CAAC,CAAC;MACzD;IACF;IAEAD,KAAK,CAACS,QAAQ,CAACC,WAAW,CAAC,IAAI,CAAC;EAClC,CAAC,EAAE,CAACT,aAAa,EAAEE,iBAAiB,EAAEC,YAAY,EAAEF,cAAc,EAAEF,KAAK,CAAC,CAAC;AAC7E,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
|
-
import { useUnit } from 'effector-react';
|
|
5
|
-
import { NO_AUDIO_BE_MESSAGE } from "../../constants.js";
|
|
6
4
|
export const useVoiceTranscriptionEffects = ({
|
|
7
5
|
model,
|
|
8
6
|
answers,
|
|
@@ -19,17 +17,6 @@ export const useVoiceTranscriptionEffects = ({
|
|
|
19
17
|
useEffect(() => {
|
|
20
18
|
model.resetPlayer();
|
|
21
19
|
}, [problemId]);
|
|
22
|
-
const transcriptsLoaded = useUnit(model.loader.$transcriptsLoaded);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (activeAttempt === null) return;
|
|
25
|
-
if (!transcriptsLoaded) {
|
|
26
|
-
model.dropdown.setExpanded(false);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const transcript = model.loader.getTranscript(activeAttempt);
|
|
30
|
-
const hasRealTranscript = !!transcript && transcript !== NO_AUDIO_BE_MESSAGE;
|
|
31
|
-
model.dropdown.setExpanded(hasRealTranscript);
|
|
32
|
-
}, [activeAttempt, transcriptsLoaded, model]);
|
|
33
20
|
useEffect(() => {
|
|
34
21
|
if (answersRef.current.some(answer => answer.audioFileId)) {
|
|
35
22
|
model.initializeWithAudios(answersRef.current);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","current","reinitializePlayer","cleanup","resetPlayer","some","answer","audioFileId","initializeWithAudios","loader","loadAllTranscripts","stopAudio"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAYzC,OAAO,MAAMC,4BAA4B,GAAGA,CAAC;EAC3CC,KAAK;EACLC,OAAO;EACPC,UAAU;EACVC,SAAS;EACTC;AACM,CAAC,KAAK;EACZ,MAAMC,UAAU,GAAGP,MAAM,CAACG,OAAO,CAAC;EAClCI,UAAU,CAACC,OAAO,GAAGL,OAAO;EAE5BJ,SAAS,CAAC,MAAM;IACdG,KAAK,CAACO,kBAAkB,CAAC,CAAC;IAC1B,OAAO,MAAMP,KAAK,CAACQ,OAAO,CAAC,CAAC;EAC9B,CAAC,EAAE,CAACR,KAAK,CAAC,CAAC;EAEXH,SAAS,CAAC,MAAM;IACdG,KAAK,CAACS,WAAW,CAAC,CAAC;EACrB,CAAC,EAAE,CAACN,SAAS,CAAC,CAAC;EAEfN,SAAS,CAAC,MAAM;IACd,IAAIQ,UAAU,CAACC,OAAO,CAACI,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,WAAW,CAAC,EAAE;MAC3DZ,KAAK,CAACa,oBAAoB,CAACR,UAAU,CAACC,OAAO,CAAC;MAC9CN,KAAK,CAACc,MAAM,CAACC,kBAAkB,CAAC,CAAC;IACnC;EACF,CAAC,EAAE,CAACf,KAAK,EAAEE,UAAU,CAAC,CAAC;EAEvBL,SAAS,CAAC,MAAM;IACdG,KAAK,CAACgB,SAAS,CAAC,CAAC;EACnB,CAAC,EAAE,CAACZ,aAAa,CAAC,CAAC;AACrB,CAAC","ignoreList":[]}
|
package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTranscription.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/components/VoiceTranscription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAIrE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"VoiceTranscription.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/components/VoiceTranscription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAIrE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAMpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAK3C,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,kBAAkB,iFAQ5B,uBAAuB,sBAgHzB,CAAA"}
|
package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VoicePlayerModel } from '../model';
|
|
2
|
+
type Params = {
|
|
3
|
+
model: VoicePlayerModel;
|
|
4
|
+
activeAttempt: number | null;
|
|
5
|
+
targetLanguage: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Auto-expands the transcription dropdown based on content readiness:
|
|
9
|
+
* - Stays collapsed during transcript loading or for drawing-only attempts.
|
|
10
|
+
* - When source language matches target, expands as soon as a real transcript is loaded.
|
|
11
|
+
* - When source differs from target, waits until the translation for that attempt is
|
|
12
|
+
* available, then expands.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useVoiceTranscriptionAutoExpand: ({ model, activeAttempt, targetLanguage, }: Params) => void;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=useVoiceTranscriptionAutoExpand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVoiceTranscriptionAutoExpand.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,gBAAgB,CAAA;IACvB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,8CAIzC,MAAM,SAiCR,CAAA"}
|
package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,4BAA4B,8DAMtC,MAAM,SAuBR,CAAA"}
|
package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTranscription.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/components/VoiceTranscription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAIrE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"VoiceTranscription.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/components/VoiceTranscription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAIrE,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAMpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAK3C,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,yBAAyB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,kBAAkB,iFAQ5B,uBAAuB,sBAgHzB,CAAA"}
|
package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VoicePlayerModel } from '../model';
|
|
2
|
+
type Params = {
|
|
3
|
+
model: VoicePlayerModel;
|
|
4
|
+
activeAttempt: number | null;
|
|
5
|
+
targetLanguage: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Auto-expands the transcription dropdown based on content readiness:
|
|
9
|
+
* - Stays collapsed during transcript loading or for drawing-only attempts.
|
|
10
|
+
* - When source language matches target, expands as soon as a real transcript is loaded.
|
|
11
|
+
* - When source differs from target, waits until the translation for that attempt is
|
|
12
|
+
* available, then expands.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useVoiceTranscriptionAutoExpand: ({ model, activeAttempt, targetLanguage, }: Params) => void;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=useVoiceTranscriptionAutoExpand.d.ts.map
|
package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVoiceTranscriptionAutoExpand.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,gBAAgB,CAAA;IACvB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,8CAIzC,MAAM,SAiCR,CAAA"}
|
package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,4BAA4B,8DAMtC,MAAM,SAuBR,CAAA"}
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import { resolveGoogleLanguageCode } from '../../../translation/providers/google
|
|
|
11
11
|
import { useText } from '../../../../i18n/i18n'
|
|
12
12
|
import { useVoiceTranscriptionEffects } from '../hooks/useVoiceTranscriptionEffects'
|
|
13
13
|
import { useVoiceTranscriptionAutoTranslate } from '../hooks/useVoiceTranscriptionAutoTranslate'
|
|
14
|
+
import { useVoiceTranscriptionAutoExpand } from '../hooks/useVoiceTranscriptionAutoExpand'
|
|
14
15
|
import { VoicePlayerModel } from '../model'
|
|
15
16
|
import { VoiceTranscriptContent } from './VoiceTranscriptContent'
|
|
16
17
|
import { VoiceTranscriptionCollapsible } from './VoiceTranscriptionCollapsible'
|
|
@@ -89,6 +90,12 @@ export const VoiceTranscription = ({
|
|
|
89
90
|
problemId,
|
|
90
91
|
})
|
|
91
92
|
|
|
93
|
+
useVoiceTranscriptionAutoExpand({
|
|
94
|
+
model,
|
|
95
|
+
activeAttempt,
|
|
96
|
+
targetLanguage: i18n.language,
|
|
97
|
+
})
|
|
98
|
+
|
|
92
99
|
useEffect(() => {
|
|
93
100
|
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
94
101
|
model.translation.translate({
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { useUnit } from 'effector-react'
|
|
3
|
+
import { NO_AUDIO_BE_MESSAGE } from '../../constants'
|
|
4
|
+
import { VoicePlayerModel } from '../model'
|
|
5
|
+
import { resolveGoogleLanguageCode } from '../../../translation/providers/google/supportedLanguages'
|
|
6
|
+
|
|
7
|
+
type Params = {
|
|
8
|
+
model: VoicePlayerModel
|
|
9
|
+
activeAttempt: number | null
|
|
10
|
+
targetLanguage: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Auto-expands the transcription dropdown based on content readiness:
|
|
15
|
+
* - Stays collapsed during transcript loading or for drawing-only attempts.
|
|
16
|
+
* - When source language matches target, expands as soon as a real transcript is loaded.
|
|
17
|
+
* - When source differs from target, waits until the translation for that attempt is
|
|
18
|
+
* available, then expands.
|
|
19
|
+
*/
|
|
20
|
+
export const useVoiceTranscriptionAutoExpand = ({
|
|
21
|
+
model,
|
|
22
|
+
activeAttempt,
|
|
23
|
+
targetLanguage,
|
|
24
|
+
}: Params) => {
|
|
25
|
+
const [transcriptsLoaded, translations] = useUnit([
|
|
26
|
+
model.loader.$transcriptsLoaded,
|
|
27
|
+
model.translation.$translations,
|
|
28
|
+
])
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (activeAttempt === null) return
|
|
32
|
+
|
|
33
|
+
if (!transcriptsLoaded) {
|
|
34
|
+
model.dropdown.setExpanded(false)
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const transcript = model.loader.getTranscript(activeAttempt)
|
|
39
|
+
const hasRealTranscript = !!transcript && transcript !== NO_AUDIO_BE_MESSAGE
|
|
40
|
+
if (!hasRealTranscript) {
|
|
41
|
+
model.dropdown.setExpanded(false)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const sourceLanguage = model.loader.getTranscriptLanguage(activeAttempt)
|
|
46
|
+
const needsTranslation =
|
|
47
|
+
!!sourceLanguage &&
|
|
48
|
+
resolveGoogleLanguageCode(sourceLanguage) !== resolveGoogleLanguageCode(targetLanguage)
|
|
49
|
+
|
|
50
|
+
if (needsTranslation) {
|
|
51
|
+
model.dropdown.setExpanded(!!translations[activeAttempt])
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
model.dropdown.setExpanded(true)
|
|
56
|
+
}, [activeAttempt, transcriptsLoaded, translations, targetLanguage, model])
|
|
57
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react'
|
|
2
|
-
import { useUnit } from 'effector-react'
|
|
3
2
|
import { AnswerAudio } from '../../types'
|
|
4
3
|
import { VoicePlayerModel } from '../model'
|
|
5
|
-
import { NO_AUDIO_BE_MESSAGE } from '../../constants'
|
|
6
4
|
|
|
7
5
|
type Params = {
|
|
8
6
|
model: VoicePlayerModel
|
|
@@ -31,19 +29,6 @@ export const useVoiceTranscriptionEffects = ({
|
|
|
31
29
|
model.resetPlayer()
|
|
32
30
|
}, [problemId])
|
|
33
31
|
|
|
34
|
-
const transcriptsLoaded = useUnit(model.loader.$transcriptsLoaded)
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (activeAttempt === null) return
|
|
38
|
-
if (!transcriptsLoaded) {
|
|
39
|
-
model.dropdown.setExpanded(false)
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
const transcript = model.loader.getTranscript(activeAttempt)
|
|
43
|
-
const hasRealTranscript = !!transcript && transcript !== NO_AUDIO_BE_MESSAGE
|
|
44
|
-
model.dropdown.setExpanded(hasRealTranscript)
|
|
45
|
-
}, [activeAttempt, transcriptsLoaded, model])
|
|
46
|
-
|
|
47
32
|
useEffect(() => {
|
|
48
33
|
if (answersRef.current.some((answer) => answer.audioFileId)) {
|
|
49
34
|
model.initializeWithAudios(answersRef.current)
|