@magmamath/students-features 1.3.23-rc.11 → 1.3.23-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.
@@ -5,6 +5,8 @@ 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");
8
10
  const useVoiceTranscriptionEffects = ({
9
11
  model,
10
12
  answers,
@@ -21,11 +23,17 @@ const useVoiceTranscriptionEffects = ({
21
23
  (0, _react.useEffect)(() => {
22
24
  model.resetPlayer();
23
25
  }, [problemId]);
26
+ const transcriptsLoaded = (0, _effectorReact.useUnit)(model.loader.$transcriptsLoaded);
24
27
  (0, _react.useEffect)(() => {
25
28
  if (activeAttempt === null) return;
26
- const hasAudio = !!answersRef.current[activeAttempt - 1]?.audioFileId;
27
- model.dropdown.setExpanded(hasAudio);
28
- }, [activeAttempt, answersKey]);
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]);
29
37
  (0, _react.useEffect)(() => {
30
38
  if (answersRef.current.some(answer => answer.audioFileId)) {
31
39
  model.initializeWithAudios(answersRef.current);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","useRef","current","useEffect","reinitializePlayer","cleanup","resetPlayer","hasAudio","audioFileId","dropdown","setExpanded","some","answer","initializeWithAudios","loader","loadAllTranscripts","stopAudio","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,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BAAA,GAAAA,4BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_effectorReact","_constants","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","useRef","current","useEffect","reinitializePlayer","cleanup","resetPlayer","transcriptsLoaded","useUnit","loader","$transcriptsLoaded","dropdown","setExpanded","transcript","getTranscript","hasRealTranscript","NO_AUDIO_BE_MESSAGE","some","answer","audioFileId","initializeWithAudios","loadAllTranscripts","stopAudio","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AAUO,MAAMG,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,MAAMS,iBAAiB,GAAG,IAAAC,sBAAO,EAACb,KAAK,CAACc,MAAM,CAACC,kBAAkB,CAAC;EAElE,IAAAP,gBAAS,EAAC,MAAM;IACd,IAAIJ,aAAa,KAAK,IAAI,EAAE;IAC5B,IAAI,CAACQ,iBAAiB,EAAE;MACtBZ,KAAK,CAACgB,QAAQ,CAACC,WAAW,CAAC,KAAK,CAAC;MACjC;IACF;IACA,MAAMC,UAAU,GAAGlB,KAAK,CAACc,MAAM,CAACK,aAAa,CAACf,aAAa,CAAC;IAC5D,MAAMgB,iBAAiB,GAAG,CAAC,CAACF,UAAU,IAAIA,UAAU,KAAKG,8BAAmB;IAC5ErB,KAAK,CAACgB,QAAQ,CAACC,WAAW,CAACG,iBAAiB,CAAC;EAC/C,CAAC,EAAE,CAAChB,aAAa,EAAEQ,iBAAiB,EAAEZ,KAAK,CAAC,CAAC;EAE7C,IAAAQ,gBAAS,EAAC,MAAM;IACd,IAAIH,UAAU,CAACE,OAAO,CAACe,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,WAAW,CAAC,EAAE;MAC3DxB,KAAK,CAACyB,oBAAoB,CAACpB,UAAU,CAACE,OAAO,CAAC;MAC9CP,KAAK,CAACc,MAAM,CAACY,kBAAkB,CAAC,CAAC;IACnC;EACF,CAAC,EAAE,CAAC1B,KAAK,EAAEE,UAAU,CAAC,CAAC;EAEvB,IAAAM,gBAAS,EAAC,MAAM;IACdR,KAAK,CAAC2B,SAAS,CAAC,CAAC;EACnB,CAAC,EAAE,CAACvB,aAAa,CAAC,CAAC;AACrB,CAAC;AAAAwB,OAAA,CAAA7B,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -1,6 +1,8 @@
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";
4
6
  export const useVoiceTranscriptionEffects = ({
5
7
  model,
6
8
  answers,
@@ -17,11 +19,17 @@ export const useVoiceTranscriptionEffects = ({
17
19
  useEffect(() => {
18
20
  model.resetPlayer();
19
21
  }, [problemId]);
22
+ const transcriptsLoaded = useUnit(model.loader.$transcriptsLoaded);
20
23
  useEffect(() => {
21
24
  if (activeAttempt === null) return;
22
- const hasAudio = !!answersRef.current[activeAttempt - 1]?.audioFileId;
23
- model.dropdown.setExpanded(hasAudio);
24
- }, [activeAttempt, answersKey]);
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]);
25
33
  useEffect(() => {
26
34
  if (answersRef.current.some(answer => answer.audioFileId)) {
27
35
  model.initializeWithAudios(answersRef.current);
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","current","reinitializePlayer","cleanup","resetPlayer","hasAudio","audioFileId","dropdown","setExpanded","some","answer","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,IAAIO,aAAa,KAAK,IAAI,EAAE;IAC5B,MAAMM,QAAQ,GAAG,CAAC,CAACL,UAAU,CAACC,OAAO,CAACF,aAAa,GAAG,CAAC,CAAC,EAAEO,WAAW;IACrEX,KAAK,CAACY,QAAQ,CAACC,WAAW,CAACH,QAAQ,CAAC;EACtC,CAAC,EAAE,CAACN,aAAa,EAAEF,UAAU,CAAC,CAAC;EAE/BL,SAAS,CAAC,MAAM;IACd,IAAIQ,UAAU,CAACC,OAAO,CAACQ,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACJ,WAAW,CAAC,EAAE;MAC3DX,KAAK,CAACgB,oBAAoB,CAACX,UAAU,CAACC,OAAO,CAAC;MAC9CN,KAAK,CAACiB,MAAM,CAACC,kBAAkB,CAAC,CAAC;IACnC;EACF,CAAC,EAAE,CAAClB,KAAK,EAAEE,UAAU,CAAC,CAAC;EAEvBL,SAAS,CAAC,MAAM;IACdG,KAAK,CAACmB,SAAS,CAAC,CAAC;EACnB,CAAC,EAAE,CAACf,aAAa,CAAC,CAAC;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useRef","useUnit","NO_AUDIO_BE_MESSAGE","useVoiceTranscriptionEffects","model","answers","answersKey","problemId","activeAttempt","answersRef","current","reinitializePlayer","cleanup","resetPlayer","transcriptsLoaded","loader","$transcriptsLoaded","dropdown","setExpanded","transcript","getTranscript","hasRealTranscript","some","answer","audioFileId","initializeWithAudios","loadAllTranscripts","stopAudio"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,OAAO,QAAQ,gBAAgB;AAGxC,SAASC,mBAAmB,QAAQ,oBAAiB;AAUrD,OAAO,MAAMC,4BAA4B,GAAGA,CAAC;EAC3CC,KAAK;EACLC,OAAO;EACPC,UAAU;EACVC,SAAS;EACTC;AACM,CAAC,KAAK;EACZ,MAAMC,UAAU,GAAGT,MAAM,CAACK,OAAO,CAAC;EAClCI,UAAU,CAACC,OAAO,GAAGL,OAAO;EAE5BN,SAAS,CAAC,MAAM;IACdK,KAAK,CAACO,kBAAkB,CAAC,CAAC;IAC1B,OAAO,MAAMP,KAAK,CAACQ,OAAO,CAAC,CAAC;EAC9B,CAAC,EAAE,CAACR,KAAK,CAAC,CAAC;EAEXL,SAAS,CAAC,MAAM;IACdK,KAAK,CAACS,WAAW,CAAC,CAAC;EACrB,CAAC,EAAE,CAACN,SAAS,CAAC,CAAC;EAEf,MAAMO,iBAAiB,GAAGb,OAAO,CAACG,KAAK,CAACW,MAAM,CAACC,kBAAkB,CAAC;EAElEjB,SAAS,CAAC,MAAM;IACd,IAAIS,aAAa,KAAK,IAAI,EAAE;IAC5B,IAAI,CAACM,iBAAiB,EAAE;MACtBV,KAAK,CAACa,QAAQ,CAACC,WAAW,CAAC,KAAK,CAAC;MACjC;IACF;IACA,MAAMC,UAAU,GAAGf,KAAK,CAACW,MAAM,CAACK,aAAa,CAACZ,aAAa,CAAC;IAC5D,MAAMa,iBAAiB,GAAG,CAAC,CAACF,UAAU,IAAIA,UAAU,KAAKjB,mBAAmB;IAC5EE,KAAK,CAACa,QAAQ,CAACC,WAAW,CAACG,iBAAiB,CAAC;EAC/C,CAAC,EAAE,CAACb,aAAa,EAAEM,iBAAiB,EAAEV,KAAK,CAAC,CAAC;EAE7CL,SAAS,CAAC,MAAM;IACd,IAAIU,UAAU,CAACC,OAAO,CAACY,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,WAAW,CAAC,EAAE;MAC3DpB,KAAK,CAACqB,oBAAoB,CAAChB,UAAU,CAACC,OAAO,CAAC;MAC9CN,KAAK,CAACW,MAAM,CAACW,kBAAkB,CAAC,CAAC;IACnC;EACF,CAAC,EAAE,CAACtB,KAAK,EAAEE,UAAU,CAAC,CAAC;EAEvBP,SAAS,CAAC,MAAM;IACdK,KAAK,CAACuB,SAAS,CAAC,CAAC;EACnB,CAAC,EAAE,CAACnB,aAAa,CAAC,CAAC;AACrB,CAAC","ignoreList":[]}
@@ -1 +1 @@
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,SA6BR,CAAA"}
1
+ {"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,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,SAoCR,CAAA"}
@@ -1 +1 @@
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,SA6BR,CAAA"}
1
+ {"version":3,"file":"useVoiceTranscriptionEffects.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,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,SAoCR,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "1.3.23-rc.11",
3
+ "version": "1.3.23-rc.12",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,8 @@
1
1
  import { useEffect, useRef } from 'react'
2
+ import { useUnit } from 'effector-react'
2
3
  import { AnswerAudio } from '../../types'
3
4
  import { VoicePlayerModel } from '../model'
5
+ import { NO_AUDIO_BE_MESSAGE } from '../../constants'
4
6
 
5
7
  type Params = {
6
8
  model: VoicePlayerModel
@@ -29,11 +31,18 @@ export const useVoiceTranscriptionEffects = ({
29
31
  model.resetPlayer()
30
32
  }, [problemId])
31
33
 
34
+ const transcriptsLoaded = useUnit(model.loader.$transcriptsLoaded)
35
+
32
36
  useEffect(() => {
33
37
  if (activeAttempt === null) return
34
- const hasAudio = !!answersRef.current[activeAttempt - 1]?.audioFileId
35
- model.dropdown.setExpanded(hasAudio)
36
- }, [activeAttempt, answersKey])
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])
37
46
 
38
47
  useEffect(() => {
39
48
  if (answersRef.current.some((answer) => answer.audioFileId)) {