@magmamath/students-features 0.11.0-rc.8 → 1.0.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/dist/commonjs/features/chatbot/components/Chat/Chat.js +49 -139
- package/dist/commonjs/features/chatbot/components/Chat/Chat.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js +58 -43
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/ChatInput.js +1 -3
- package/dist/commonjs/features/chatbot/components/ChatInput/ChatInput.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/FreeText/ChatTextInput.js +2 -2
- package/dist/commonjs/features/chatbot/components/ChatInput/FreeText/ChatTextInput.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/FreeText/SendMessageButton.js +1 -1
- package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js +36 -11
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +8 -48
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js +20 -14
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js +1 -1
- package/dist/commonjs/features/chatbot/components/Chatbot.js +12 -22
- package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/commonjs/features/chatbot/constants.js +4 -4
- package/dist/commonjs/features/chatbot/constants.js.map +1 -1
- package/dist/commonjs/features/chatbot/helpers.js +1 -8
- package/dist/commonjs/features/chatbot/helpers.js.map +1 -1
- package/dist/commonjs/features/chatbot/index.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +10 -46
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatbotApi.js +1 -1
- package/dist/commonjs/features/chatbot/model/ChatbotApi.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js +0 -9
- package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/commonjs/features/gifCelebrations/helpers.js +1 -0
- package/dist/commonjs/features/gifCelebrations/helpers.js.map +1 -1
- package/dist/commonjs/features/voice/constants.js +23 -0
- package/dist/commonjs/features/voice/constants.js.map +1 -0
- package/dist/commonjs/features/voice/helpers.js +208 -0
- package/dist/commonjs/features/voice/helpers.js.map +1 -0
- package/dist/commonjs/features/voice/index.js +105 -0
- package/dist/commonjs/features/voice/index.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceIcon.js +49 -0
- package/dist/commonjs/features/voice/playing/components/VoiceIcon.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js +215 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +108 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js +50 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +34 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/Player.model.js +98 -0
- package/dist/commonjs/features/voice/playing/model/Player.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +66 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js +39 -0
- package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +223 -0
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js +41 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js +15 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/index.js +20 -0
- package/dist/commonjs/features/voice/playing/model/index.js.map +1 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecord.js +74 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecord.js.map +1 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js +63 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js.map +1 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.js +35 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.js.map +1 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordDivider.js +27 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordDivider.js.map +1 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordTimer.js +50 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordTimer.js.map +1 -0
- package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorder.js +59 -0
- package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorder.js.map +1 -0
- package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.js +22 -0
- package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.js.map +1 -0
- package/dist/commonjs/features/voice/recording/modal/ModalFooterButtons.js +53 -0
- package/dist/commonjs/features/voice/recording/modal/ModalFooterButtons.js.map +1 -0
- package/dist/commonjs/features/voice/recording/modal/VoiceRecordDeleteModal.js +78 -0
- package/dist/commonjs/features/voice/recording/modal/VoiceRecordDeleteModal.js.map +1 -0
- package/dist/commonjs/features/voice/recording/modal/VoiceRecordUndoModal.js +51 -0
- package/dist/commonjs/features/voice/recording/modal/VoiceRecordUndoModal.js.map +1 -0
- package/dist/commonjs/features/voice/recording/model/Recorder.model.js +55 -0
- package/dist/commonjs/features/voice/recording/model/Recorder.model.js.map +1 -0
- package/dist/commonjs/features/voice/recording/model/Uploader.model.js +44 -0
- package/dist/commonjs/features/voice/recording/model/Uploader.model.js.map +1 -0
- package/dist/commonjs/features/voice/recording/model/VoiceRecord.model.js +248 -0
- package/dist/commonjs/features/voice/recording/model/VoiceRecord.model.js.map +1 -0
- package/dist/commonjs/features/voice/recording/model/VoiceRecordCollection.js +30 -0
- package/dist/commonjs/features/voice/recording/model/VoiceRecordCollection.js.map +1 -0
- package/dist/commonjs/features/voice/types.js +6 -0
- package/dist/commonjs/features/voice/types.js.map +1 -0
- package/dist/commonjs/index.js +12 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/shared/components/PlayButton.js +70 -0
- package/dist/commonjs/shared/components/PlayButton.js.map +1 -0
- package/dist/commonjs/shared/translation/localization/ca.json +17 -0
- package/dist/commonjs/shared/translation/localization/de.json +17 -0
- package/dist/commonjs/shared/translation/localization/en.json +17 -0
- package/dist/commonjs/shared/translation/localization/gb.json +17 -0
- package/dist/commonjs/shared/translation/localization/sct.json +17 -0
- package/dist/commonjs/shared/translation/localization/sw.json +17 -0
- package/dist/module/features/chatbot/components/Chat/Chat.js +51 -141
- package/dist/module/features/chatbot/components/Chat/Chat.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +59 -45
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatInput/ChatInput.js +1 -3
- package/dist/module/features/chatbot/components/ChatInput/ChatInput.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatInput/FreeText/ChatTextInput.js +2 -2
- package/dist/module/features/chatbot/components/ChatInput/FreeText/ChatTextInput.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatInput/FreeText/SendMessageButton.js +1 -1
- package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js +38 -14
- package/dist/module/features/chatbot/components/ChatMessage/MessageLoader.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +9 -49
- package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js +21 -15
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js +1 -1
- package/dist/module/features/chatbot/components/Chatbot.js +11 -20
- package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/module/features/chatbot/constants.js +5 -5
- package/dist/module/features/chatbot/constants.js.map +1 -1
- package/dist/module/features/chatbot/helpers.js +1 -8
- package/dist/module/features/chatbot/helpers.js.map +1 -1
- package/dist/module/features/chatbot/index.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js +10 -46
- package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatbotApi.js +1 -1
- package/dist/module/features/chatbot/model/ChatbotApi.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatsCacheModel.js +0 -9
- package/dist/module/features/chatbot/model/ChatsCacheModel.js.map +1 -1
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/features/gifCelebrations/helpers.js +1 -0
- package/dist/module/features/gifCelebrations/helpers.js.map +1 -1
- package/dist/module/features/voice/constants.js +19 -0
- package/dist/module/features/voice/constants.js.map +1 -0
- package/dist/module/features/voice/helpers.js +191 -0
- package/dist/module/features/voice/helpers.js.map +1 -0
- package/dist/module/features/voice/index.js +12 -0
- package/dist/module/features/voice/index.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceIcon.js +41 -0
- package/dist/module/features/voice/playing/components/VoiceIcon.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js +208 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +102 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js +45 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +29 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +1 -0
- package/dist/module/features/voice/playing/model/Player.model.js +93 -0
- package/dist/module/features/voice/playing/model/Player.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +61 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js +34 -0
- package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js +218 -0
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js +36 -0
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js +10 -0
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/index.js +5 -0
- package/dist/module/features/voice/playing/model/index.js.map +1 -0
- package/dist/module/features/voice/recording/components/VoiceRecord.js +67 -0
- package/dist/module/features/voice/recording/components/VoiceRecord.js.map +1 -0
- package/dist/module/features/voice/recording/components/VoiceRecordButton.js +57 -0
- package/dist/module/features/voice/recording/components/VoiceRecordButton.js.map +1 -0
- package/dist/module/features/voice/recording/components/VoiceRecordDeleteButton.js +29 -0
- package/dist/module/features/voice/recording/components/VoiceRecordDeleteButton.js.map +1 -0
- package/dist/module/features/voice/recording/components/VoiceRecordDivider.js +21 -0
- package/dist/module/features/voice/recording/components/VoiceRecordDivider.js.map +1 -0
- package/dist/module/features/voice/recording/components/VoiceRecordTimer.js +44 -0
- package/dist/module/features/voice/recording/components/VoiceRecordTimer.js.map +1 -0
- package/dist/module/features/voice/recording/hooks/useVoiceRecorder.js +54 -0
- package/dist/module/features/voice/recording/hooks/useVoiceRecorder.js.map +1 -0
- package/dist/module/features/voice/recording/hooks/useVoiceRecorderAnimation.js +17 -0
- package/dist/module/features/voice/recording/hooks/useVoiceRecorderAnimation.js.map +1 -0
- package/dist/module/features/voice/recording/modal/ModalFooterButtons.js +47 -0
- package/dist/module/features/voice/recording/modal/ModalFooterButtons.js.map +1 -0
- package/dist/module/features/voice/recording/modal/VoiceRecordDeleteModal.js +71 -0
- package/dist/module/features/voice/recording/modal/VoiceRecordDeleteModal.js.map +1 -0
- package/dist/module/features/voice/recording/modal/VoiceRecordUndoModal.js +45 -0
- package/dist/module/features/voice/recording/modal/VoiceRecordUndoModal.js.map +1 -0
- package/dist/module/features/voice/recording/model/Recorder.model.js +50 -0
- package/dist/module/features/voice/recording/model/Recorder.model.js.map +1 -0
- package/dist/module/features/voice/recording/model/Uploader.model.js +39 -0
- package/dist/module/features/voice/recording/model/Uploader.model.js.map +1 -0
- package/dist/module/features/voice/recording/model/VoiceRecord.model.js +244 -0
- package/dist/module/features/voice/recording/model/VoiceRecord.model.js.map +1 -0
- package/dist/module/features/voice/recording/model/VoiceRecordCollection.js +25 -0
- package/dist/module/features/voice/recording/model/VoiceRecordCollection.js.map +1 -0
- package/dist/module/features/voice/types.js +4 -0
- package/dist/module/features/voice/types.js.map +1 -0
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/shared/components/PlayButton.js +64 -0
- package/dist/module/shared/components/PlayButton.js.map +1 -0
- package/dist/module/shared/translation/localization/ca.json +17 -0
- package/dist/module/shared/translation/localization/de.json +17 -0
- package/dist/module/shared/translation/localization/en.json +17 -0
- package/dist/module/shared/translation/localization/gb.json +17 -0
- package/dist/module/shared/translation/localization/sct.json +17 -0
- package/dist/module/shared/translation/localization/sw.json +17 -0
- package/dist/typescript/commonjs/features/chatbot/components/Chat/Chat.d.ts +1 -2
- package/dist/typescript/commonjs/features/chatbot/components/Chat/Chat.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts +3 -3
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/ChatInput.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts +6 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +2 -2
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +1 -2
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts +5 -5
- package/dist/typescript/commonjs/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/index.d.ts +2 -2
- package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +1 -2
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts +0 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +17 -19
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +13 -7
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +0 -1
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/constants.d.ts +16 -0
- package/dist/typescript/commonjs/features/voice/constants.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/helpers.d.ts +46 -0
- package/dist/typescript/commonjs/features/voice/helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/index.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceIcon.d.ts +8 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +16 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +12 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts +16 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +11 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts +23 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +15 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts +17 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +41 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts +13 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts +7 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/index.d.ts +3 -0
- package/dist/typescript/commonjs/features/voice/playing/model/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecord.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecord.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.d.ts +8 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordDivider.d.ts +3 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordDivider.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordTimer.d.ts +11 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordTimer.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorder.d.ts +5 -0
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorder.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts +6 -0
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/modal/ModalFooterButtons.d.ts +12 -0
- package/dist/typescript/commonjs/features/voice/recording/modal/ModalFooterButtons.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/modal/VoiceRecordDeleteModal.d.ts +11 -0
- package/dist/typescript/commonjs/features/voice/recording/modal/VoiceRecordDeleteModal.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/modal/VoiceRecordUndoModal.d.ts +11 -0
- package/dist/typescript/commonjs/features/voice/recording/modal/VoiceRecordUndoModal.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/model/Recorder.model.d.ts +19 -0
- package/dist/typescript/commonjs/features/voice/recording/model/Recorder.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/model/Uploader.model.d.ts +18 -0
- package/dist/typescript/commonjs/features/voice/recording/model/Uploader.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecord.model.d.ts +50 -0
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecord.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecordCollection.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecordCollection.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/types.d.ts +72 -0
- package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -0
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/components/PlayButton.d.ts +18 -0
- package/dist/typescript/commonjs/shared/components/PlayButton.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/translation/constants.d.ts +102 -0
- package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/model.d.ts +34 -0
- package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
- package/dist/typescript/commonjs/types/common.types.d.ts +3 -0
- package/dist/typescript/commonjs/types/common.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Chat/Chat.d.ts +1 -2
- package/dist/typescript/module/features/chatbot/components/Chat/Chat.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts +3 -3
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/ChatInput.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts +6 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageLoader.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +2 -2
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +1 -2
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/constants.d.ts +5 -5
- package/dist/typescript/module/features/chatbot/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/index.d.ts +2 -2
- package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +1 -2
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts +0 -1
- package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts +17 -19
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts +13 -7
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts +0 -1
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +1 -1
- package/dist/typescript/module/features/gifCelebrations/helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/constants.d.ts +16 -0
- package/dist/typescript/module/features/voice/constants.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/helpers.d.ts +46 -0
- package/dist/typescript/module/features/voice/helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/index.d.ts +10 -0
- package/dist/typescript/module/features/voice/index.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceIcon.d.ts +8 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceIcon.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +16 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +12 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts +16 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +11 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts +23 -0
- package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +15 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts +17 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +41 -0
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts +13 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts +7 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/index.d.ts +3 -0
- package/dist/typescript/module/features/voice/playing/model/index.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecord.d.ts +10 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecord.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts +10 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordDeleteButton.d.ts +8 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordDeleteButton.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordDivider.d.ts +3 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordDivider.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordTimer.d.ts +11 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordTimer.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorder.d.ts +5 -0
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorder.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts +6 -0
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/modal/ModalFooterButtons.d.ts +12 -0
- package/dist/typescript/module/features/voice/recording/modal/ModalFooterButtons.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/modal/VoiceRecordDeleteModal.d.ts +11 -0
- package/dist/typescript/module/features/voice/recording/modal/VoiceRecordDeleteModal.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/modal/VoiceRecordUndoModal.d.ts +11 -0
- package/dist/typescript/module/features/voice/recording/modal/VoiceRecordUndoModal.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/model/Recorder.model.d.ts +19 -0
- package/dist/typescript/module/features/voice/recording/model/Recorder.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/model/Uploader.model.d.ts +18 -0
- package/dist/typescript/module/features/voice/recording/model/Uploader.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/model/VoiceRecord.model.d.ts +50 -0
- package/dist/typescript/module/features/voice/recording/model/VoiceRecord.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/model/VoiceRecordCollection.d.ts +10 -0
- package/dist/typescript/module/features/voice/recording/model/VoiceRecordCollection.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/types.d.ts +72 -0
- package/dist/typescript/module/features/voice/types.d.ts.map +1 -0
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/dist/typescript/module/shared/components/PlayButton.d.ts +18 -0
- package/dist/typescript/module/shared/components/PlayButton.d.ts.map +1 -0
- package/dist/typescript/module/shared/translation/constants.d.ts +102 -0
- package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/model.d.ts +34 -0
- package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
- package/dist/typescript/module/types/common.types.d.ts +3 -0
- package/dist/typescript/module/types/common.types.d.ts.map +1 -1
- package/package.json +11 -4
- package/src/features/chatbot/components/Chat/Chat.tsx +69 -192
- package/src/features/chatbot/components/ChatControls/ChatControls.tsx +66 -44
- package/src/features/chatbot/components/ChatInput/ChatInput.tsx +1 -3
- package/src/features/chatbot/components/ChatInput/FreeText/ChatTextInput.tsx +2 -2
- package/src/features/chatbot/components/ChatInput/FreeText/SendMessageButton.tsx +1 -1
- package/src/features/chatbot/components/ChatInput/RequestHintButton.tsx +0 -1
- package/src/features/chatbot/components/ChatMessage/ChatMessage.tsx +1 -0
- package/src/features/chatbot/components/ChatMessage/MessageButtonsBlock.tsx +1 -1
- package/src/features/chatbot/components/ChatMessage/MessageLoader.tsx +35 -11
- package/src/features/chatbot/components/ChatMessage/MessageTextToSpeech.tsx +9 -51
- package/src/features/chatbot/components/ChatMessage/ReceivedMessage.tsx +17 -11
- package/src/features/chatbot/components/ChatMessage/SentMessage.tsx +1 -1
- package/src/features/chatbot/components/Chatbot.tsx +11 -21
- package/src/features/chatbot/constants.ts +4 -4
- package/src/features/chatbot/helpers.ts +0 -3
- package/src/features/chatbot/index.ts +2 -16
- package/src/features/chatbot/model/ChatBotModel.ts +8 -51
- package/src/features/chatbot/model/ChatbotApi.ts +1 -1
- package/src/features/chatbot/model/ChatsCacheModel.ts +0 -7
- package/src/features/chatbot/types/api.types.ts +17 -17
- package/src/features/chatbot/types/model.types.ts +15 -7
- package/src/features/chatbot/types/units.types.ts +0 -1
- package/src/features/gifCelebrations/helpers.ts +1 -0
- package/src/features/voice/constants.ts +15 -0
- package/src/features/voice/helpers.ts +251 -0
- package/src/features/voice/index.ts +11 -0
- package/src/features/voice/playing/components/VoiceIcon.tsx +38 -0
- package/src/features/voice/playing/components/VoiceTranscriptionsDropdown.tsx +251 -0
- package/src/features/voice/playing/components/VoiceTranscriptionsDropdownItem.tsx +127 -0
- package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.ts +54 -0
- package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.ts +40 -0
- package/src/features/voice/playing/model/Player.model.ts +104 -0
- package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +80 -0
- package/src/features/voice/playing/model/VoiceFileDownloader.model.ts +42 -0
- package/src/features/voice/playing/model/VoicePlayer.model.ts +255 -0
- package/src/features/voice/playing/model/VoiceTranscriptionsCollection.ts +40 -0
- package/src/features/voice/playing/model/VoiceTranscriptionsDropdown.model.ts +11 -0
- package/src/features/voice/playing/model/index.ts +2 -0
- package/src/features/voice/recording/components/VoiceRecord.tsx +65 -0
- package/src/features/voice/recording/components/VoiceRecordButton.tsx +64 -0
- package/src/features/voice/recording/components/VoiceRecordDeleteButton.tsx +25 -0
- package/src/features/voice/recording/components/VoiceRecordDivider.tsx +17 -0
- package/src/features/voice/recording/components/VoiceRecordTimer.tsx +49 -0
- package/src/features/voice/recording/hooks/useVoiceRecorder.ts +62 -0
- package/src/features/voice/recording/hooks/useVoiceRecorderAnimation.ts +19 -0
- package/src/features/voice/recording/modal/ModalFooterButtons.tsx +54 -0
- package/src/features/voice/recording/modal/VoiceRecordDeleteModal.tsx +82 -0
- package/src/features/voice/recording/modal/VoiceRecordUndoModal.tsx +50 -0
- package/src/features/voice/recording/model/Recorder.model.ts +63 -0
- package/src/features/voice/recording/model/Uploader.model.ts +48 -0
- package/src/features/voice/recording/model/VoiceRecord.model.ts +302 -0
- package/src/features/voice/recording/model/VoiceRecordCollection.ts +26 -0
- package/src/features/voice/types.ts +84 -0
- package/src/index.ts +1 -0
- package/src/shared/components/PlayButton.tsx +84 -0
- package/src/shared/translation/localization/ca.json +17 -0
- package/src/shared/translation/localization/de.json +17 -0
- package/src/shared/translation/localization/en.json +17 -0
- package/src/shared/translation/localization/gb.json +17 -0
- package/src/shared/translation/localization/sct.json +17 -0
- package/src/shared/translation/localization/sw.json +17 -0
- package/src/types/common.types.ts +1 -0
- package/dist/commonjs/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
- package/dist/commonjs/features/chatbot/components/Chat/CloseButton.js +0 -39
- package/dist/commonjs/features/chatbot/components/Chat/CloseButton.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/AnimatedMessage.js +0 -43
- package/dist/commonjs/features/chatbot/components/ChatMessage/AnimatedMessage.js.map +0 -1
- package/dist/module/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
- package/dist/module/features/chatbot/components/Chat/CloseButton.js +0 -33
- package/dist/module/features/chatbot/components/Chat/CloseButton.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatMessage/AnimatedMessage.js +0 -40
- package/dist/module/features/chatbot/components/ChatMessage/AnimatedMessage.js.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/Chat/CloseButton.d.ts +0 -7
- package/dist/typescript/commonjs/features/chatbot/components/Chat/CloseButton.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/AnimatedMessage.d.ts +0 -7
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/AnimatedMessage.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/Chat/CloseButton.d.ts +0 -7
- package/dist/typescript/module/features/chatbot/components/Chat/CloseButton.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/AnimatedMessage.d.ts +0 -7
- package/dist/typescript/module/features/chatbot/components/ChatMessage/AnimatedMessage.d.ts.map +0 -1
- package/src/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
- package/src/features/chatbot/components/Chat/CloseButton.tsx +0 -31
- package/src/features/chatbot/components/ChatMessage/AnimatedMessage.tsx +0 -38
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { useUnit } from 'effector-react'
|
|
3
|
+
import { useAnimatedStyle, useSharedValue, withTiming, interpolate } from 'react-native-reanimated'
|
|
4
|
+
import { VoiceTranscriptionsDropdownModel } from '../model/VoiceTranscriptionsDropdown.model'
|
|
5
|
+
import { DROPDOWN_MAX_CONTENT_HEIGHT } from '../../constants'
|
|
6
|
+
import { LayoutChangeEvent } from 'react-native'
|
|
7
|
+
|
|
8
|
+
export const useVoiceTranscriptionsDropdown = (model: VoiceTranscriptionsDropdownModel) => {
|
|
9
|
+
const isExpanded = useUnit(model.$isExpanded)
|
|
10
|
+
|
|
11
|
+
const contentHeight = useSharedValue(0)
|
|
12
|
+
const animationProgress = useSharedValue(isExpanded ? 1 : 0)
|
|
13
|
+
|
|
14
|
+
const onListLayout = (event: LayoutChangeEvent) => {
|
|
15
|
+
const measuredHeight = event.nativeEvent.layout.height
|
|
16
|
+
if (measuredHeight > 0) {
|
|
17
|
+
contentHeight.value = measuredHeight
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const listAnimatedStyle = useAnimatedStyle(() => {
|
|
22
|
+
const height = interpolate(
|
|
23
|
+
animationProgress.value,
|
|
24
|
+
[0, 1],
|
|
25
|
+
[0, contentHeight.value || DROPDOWN_MAX_CONTENT_HEIGHT],
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const opacity = interpolate(animationProgress.value, [0, 0.3, 1], [0, 0, 1])
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
height,
|
|
32
|
+
opacity,
|
|
33
|
+
}
|
|
34
|
+
}, [animationProgress, contentHeight])
|
|
35
|
+
|
|
36
|
+
const iconAnimatedStyle = useAnimatedStyle(() => {
|
|
37
|
+
const rotation = interpolate(animationProgress.value, [0, 1], [0, 180])
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
transform: [{ rotate: `${rotation}deg` }],
|
|
41
|
+
}
|
|
42
|
+
}, [animationProgress])
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
animationProgress.value = withTiming(isExpanded ? 1 : 0, { duration: 300 })
|
|
46
|
+
}, [isExpanded, animationProgress])
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
isExpanded,
|
|
50
|
+
listAnimatedStyle,
|
|
51
|
+
iconAnimatedStyle,
|
|
52
|
+
onListLayout,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { LayoutChangeEvent } from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
useSharedValue,
|
|
5
|
+
withTiming,
|
|
6
|
+
useDerivedValue,
|
|
7
|
+
useAnimatedStyle,
|
|
8
|
+
interpolate,
|
|
9
|
+
} from 'react-native-reanimated'
|
|
10
|
+
|
|
11
|
+
export const useVoiceTranscriptionsDropdownItemAnimation = (isExpanded: boolean) => {
|
|
12
|
+
const height = useSharedValue(0)
|
|
13
|
+
const progress = useSharedValue(isExpanded ? 1 : 0)
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
progress.value = withTiming(isExpanded ? 1 : 0)
|
|
17
|
+
}, [isExpanded, progress])
|
|
18
|
+
|
|
19
|
+
const derivedHeight = useDerivedValue(() => height.value * progress.value, [height, progress])
|
|
20
|
+
|
|
21
|
+
const contentAnimatedStyle = useAnimatedStyle(() => {
|
|
22
|
+
const opacity = interpolate(progress.value, [0, 0.3, 1], [0, 0, 1])
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
height: derivedHeight.value,
|
|
26
|
+
opacity,
|
|
27
|
+
overflow: 'hidden',
|
|
28
|
+
}
|
|
29
|
+
}, [progress, derivedHeight])
|
|
30
|
+
|
|
31
|
+
const onLayout = (event: LayoutChangeEvent) => {
|
|
32
|
+
height.value = event.nativeEvent.layout.height
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
contentAnimatedStyle,
|
|
37
|
+
onLayout,
|
|
38
|
+
progress,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { createEffect, createEvent, restore } from 'effector'
|
|
2
|
+
import { AudioPlayer, createAudioPlayer, setAudioModeAsync } from 'expo-audio'
|
|
3
|
+
|
|
4
|
+
export const enum PlayerState {
|
|
5
|
+
PLAYING = 'playing',
|
|
6
|
+
PAUSED = 'paused',
|
|
7
|
+
LOADING = 'loading',
|
|
8
|
+
IDLE = 'idle',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class PlayerModel {
|
|
12
|
+
public player: AudioPlayer | null = createAudioPlayer()
|
|
13
|
+
private stopped = false
|
|
14
|
+
|
|
15
|
+
public readonly reset = createEvent()
|
|
16
|
+
public readonly setPlayerState = createEvent<PlayerState>()
|
|
17
|
+
public readonly playbackFinished = createEvent()
|
|
18
|
+
|
|
19
|
+
public readonly $playerState = restore(this.setPlayerState, PlayerState.IDLE).reset(this.reset)
|
|
20
|
+
|
|
21
|
+
public readonly setupAudioMode = createEffect(async () => {
|
|
22
|
+
await setAudioModeAsync({
|
|
23
|
+
playsInSilentMode: true,
|
|
24
|
+
shouldPlayInBackground: false,
|
|
25
|
+
interruptionMode: 'doNotMix',
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
public readonly pause = createEffect(() => {
|
|
30
|
+
if (this.player) {
|
|
31
|
+
this.player.pause()
|
|
32
|
+
this.setPlayerState(PlayerState.PAUSED)
|
|
33
|
+
} else {
|
|
34
|
+
console.warn('Cannot pause: audio player not initialized')
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
public readonly stop = createEffect(() => {
|
|
39
|
+
this.stopped = true
|
|
40
|
+
if (this.player) {
|
|
41
|
+
this.player.replace('')
|
|
42
|
+
this.setPlayerState(PlayerState.IDLE)
|
|
43
|
+
} else {
|
|
44
|
+
console.warn('Cannot stop: audio player not initialized')
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
public readonly resume = createEffect(() => {
|
|
49
|
+
if (this.player) {
|
|
50
|
+
this.player.play()
|
|
51
|
+
this.setPlayerState(PlayerState.PLAYING)
|
|
52
|
+
} else {
|
|
53
|
+
console.warn('Cannot resume: audio player not initialized')
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
public readonly play = createEffect(async (uri: string) => {
|
|
58
|
+
if (!this.player) {
|
|
59
|
+
console.warn('Audio player not initialized')
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.stopped = false
|
|
64
|
+
this.player.replace(uri)
|
|
65
|
+
|
|
66
|
+
const waitForLoad = () => {
|
|
67
|
+
if (this.stopped) return
|
|
68
|
+
if (this.player && this.player.isLoaded) {
|
|
69
|
+
const unsubscribe = this.player.addListener('playbackStatusUpdate', (status) => {
|
|
70
|
+
if (status.didJustFinish) {
|
|
71
|
+
this.playbackFinished()
|
|
72
|
+
unsubscribe?.remove?.()
|
|
73
|
+
this.setPlayerState(PlayerState.IDLE)
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
this.player.play()
|
|
78
|
+
this.setPlayerState(PlayerState.PLAYING)
|
|
79
|
+
} else {
|
|
80
|
+
setTimeout(waitForLoad, 10)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
waitForLoad()
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
public reinitialize() {
|
|
88
|
+
if (!this.player) {
|
|
89
|
+
this.player = createAudioPlayer()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public release() {
|
|
94
|
+
if (this.player) {
|
|
95
|
+
try {
|
|
96
|
+
this.stop()
|
|
97
|
+
this.player.remove()
|
|
98
|
+
} catch (error) {}
|
|
99
|
+
this.player.release()
|
|
100
|
+
this.player = null
|
|
101
|
+
}
|
|
102
|
+
this.reset()
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createEffect, createEvent, restore } from 'effector'
|
|
2
|
+
import { VoiceTranscriptionsCollection } from './VoiceTranscriptionsCollection'
|
|
3
|
+
import { VoicePlayerApi } from '../../types'
|
|
4
|
+
import {
|
|
5
|
+
NO_AUDIO_BE_MESSAGE,
|
|
6
|
+
TRANSCRIPT_MAX_RETRIES,
|
|
7
|
+
TRANSCRIPT_RETRY_INTERVAL_MS,
|
|
8
|
+
} from '../../constants'
|
|
9
|
+
|
|
10
|
+
export class TranscriptionsDownloaderModel {
|
|
11
|
+
private readonly collection: VoiceTranscriptionsCollection
|
|
12
|
+
private readonly api: VoicePlayerApi
|
|
13
|
+
|
|
14
|
+
public readonly setTranscriptsLoaded = createEvent<boolean>()
|
|
15
|
+
public readonly reset = createEvent()
|
|
16
|
+
|
|
17
|
+
public readonly $transcriptsLoaded = restore(this.setTranscriptsLoaded, false).reset(this.reset)
|
|
18
|
+
|
|
19
|
+
constructor(collection: VoiceTranscriptionsCollection, api: VoicePlayerApi) {
|
|
20
|
+
this.collection = collection
|
|
21
|
+
this.api = api
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private async fetchTranscriptWithRetry(audioFileId: string): Promise<string> {
|
|
25
|
+
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
26
|
+
const response = await this.api.getAudioFileTranscript(audioFileId)
|
|
27
|
+
|
|
28
|
+
if (response.status === 'completed') {
|
|
29
|
+
return response.text
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (response.status === 'failed') {
|
|
33
|
+
return NO_AUDIO_BE_MESSAGE
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
37
|
+
await new Promise((resolve) => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return NO_AUDIO_BE_MESSAGE
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public readonly loadAllTranscripts = createEffect(async () => {
|
|
44
|
+
const attempts = this.collection.getAll()
|
|
45
|
+
|
|
46
|
+
const transcriptPromises = attempts.map(async (item) => {
|
|
47
|
+
if (this.collection.hasTranscript(item.attemptNumber)) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.collection.update(item.attemptNumber, { transcriptLoading: true })
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const text = await this.fetchTranscriptWithRetry(item.audioFileId)
|
|
55
|
+
|
|
56
|
+
this.collection.update(item.attemptNumber, {
|
|
57
|
+
transcript: text,
|
|
58
|
+
transcriptLoading: false,
|
|
59
|
+
transcriptError: undefined,
|
|
60
|
+
})
|
|
61
|
+
} catch (error) {
|
|
62
|
+
this.collection.update(item.attemptNumber, {
|
|
63
|
+
transcriptLoading: false,
|
|
64
|
+
transcriptError: error instanceof Error ? error.message : 'Failed to load transcript',
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
await Promise.all(transcriptPromises)
|
|
70
|
+
this.setTranscriptsLoaded(true)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
public getTranscript(attemptNumber: number): string | undefined {
|
|
74
|
+
return this.collection.get(attemptNumber)?.transcript
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public isTranscriptLoading(attemptNumber: number): boolean {
|
|
78
|
+
return this.collection.get(attemptNumber)?.transcriptLoading || false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createEffect } from 'effector'
|
|
2
|
+
import { VoicePlayerApi, VoiceTranscriptionItem } from '../../types'
|
|
3
|
+
import { downloadAudioFileRequestGenerator } from '../../helpers'
|
|
4
|
+
|
|
5
|
+
type DownloadParams = {
|
|
6
|
+
audioFileId: string
|
|
7
|
+
attemptNumber: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type DownloadResult = {
|
|
11
|
+
collectionItem: Partial<VoiceTranscriptionItem>
|
|
12
|
+
downloadPromise: Promise<any>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class VoiceFileDownloaderModel {
|
|
16
|
+
private api!: VoicePlayerApi
|
|
17
|
+
|
|
18
|
+
public readonly setApi = (api: VoicePlayerApi) => {
|
|
19
|
+
this.api = api
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public readonly download = createEffect(
|
|
23
|
+
async ({ audioFileId, attemptNumber }: DownloadParams): Promise<DownloadResult> => {
|
|
24
|
+
const { downloadAudio, controller } = downloadAudioFileRequestGenerator(audioFileId, this.api)
|
|
25
|
+
const downloadPromise = downloadAudio()
|
|
26
|
+
|
|
27
|
+
const collectionItem: Partial<VoiceTranscriptionItem> = {
|
|
28
|
+
attemptNumber,
|
|
29
|
+
audioFileId,
|
|
30
|
+
audioLoading: true,
|
|
31
|
+
audioDownloadPromise: downloadPromise,
|
|
32
|
+
controller,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return { collectionItem, downloadPromise }
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
public readonly abortDownload = (controller?: AbortController) => {
|
|
40
|
+
controller?.abort()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { attach, createEffect, createEvent, restore } from 'effector'
|
|
2
|
+
import { VoiceTranscriptionsCollection } from './VoiceTranscriptionsCollection'
|
|
3
|
+
import { VoiceFileDownloaderModel } from './VoiceFileDownloader.model'
|
|
4
|
+
import { VoiceTranscriptionsDropdownModel } from './VoiceTranscriptionsDropdown.model'
|
|
5
|
+
import { AnswerAudio, VoicePlayerApi, VoiceTranscriptionItem } from '../../types'
|
|
6
|
+
import { PlayerModel, PlayerState } from './Player.model'
|
|
7
|
+
import { TranscriptionsDownloaderModel } from './TranscriptionsDownloaderModel'
|
|
8
|
+
|
|
9
|
+
type VoiceTranscriptionsPlayerModelParams = {
|
|
10
|
+
api: VoicePlayerApi
|
|
11
|
+
audios?: AnswerAudio[]
|
|
12
|
+
}
|
|
13
|
+
type TogglePlayPauseParams = {
|
|
14
|
+
attemptNumber: number
|
|
15
|
+
playerState: PlayerState
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class VoicePlayerModel {
|
|
19
|
+
public readonly collection = new VoiceTranscriptionsCollection()
|
|
20
|
+
public readonly downloader = new VoiceFileDownloaderModel()
|
|
21
|
+
public readonly dropdown = new VoiceTranscriptionsDropdownModel()
|
|
22
|
+
public readonly playerModel = new PlayerModel()
|
|
23
|
+
public readonly loader: TranscriptionsDownloaderModel
|
|
24
|
+
public readonly api: VoicePlayerApi
|
|
25
|
+
private currentPlayingAttempt: number | null = null
|
|
26
|
+
private shouldPreventPlayback = false
|
|
27
|
+
|
|
28
|
+
public readonly setCurrentAttempt = createEvent<number | null>()
|
|
29
|
+
public readonly reset = createEvent()
|
|
30
|
+
|
|
31
|
+
public readonly $currentAttempt = restore(this.setCurrentAttempt, null).reset(this.reset)
|
|
32
|
+
public readonly $playerState = this.playerModel.$playerState
|
|
33
|
+
|
|
34
|
+
public readonly pauseAudio = this.playerModel.pause
|
|
35
|
+
|
|
36
|
+
public readonly stopAudio = () => {
|
|
37
|
+
this.shouldPreventPlayback = true
|
|
38
|
+
this.abortAllDownloads()
|
|
39
|
+
this.playerModel.stop()
|
|
40
|
+
this.currentPlayingAttempt = null
|
|
41
|
+
this.setCurrentAttempt(null)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public readonly resetPlayer = () => {
|
|
45
|
+
this.shouldPreventPlayback = true
|
|
46
|
+
this.releaseCollectionResources()
|
|
47
|
+
this.playerModel.stop()
|
|
48
|
+
this.currentPlayingAttempt = null
|
|
49
|
+
this.setCurrentAttempt(null)
|
|
50
|
+
this.collection.clear()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
constructor(params: VoiceTranscriptionsPlayerModelParams) {
|
|
54
|
+
this.api = params.api
|
|
55
|
+
this.loader = new TranscriptionsDownloaderModel(this.collection, params.api)
|
|
56
|
+
this.downloader.setApi(params.api)
|
|
57
|
+
|
|
58
|
+
this.playerModel.playbackFinished.watch(() => {
|
|
59
|
+
this.currentPlayingAttempt = null
|
|
60
|
+
this.setCurrentAttempt(null)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
if (params.audios) {
|
|
64
|
+
this.initializeCollectionFromAudios(params.audios)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.playerModel.setupAudioMode()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public initializeWithAudios(answerAudio: AnswerAudio[]) {
|
|
71
|
+
this.loader.setTranscriptsLoaded(false)
|
|
72
|
+
this.collection.clear()
|
|
73
|
+
this.initializeCollectionFromAudios(answerAudio)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private initializeCollectionFromAudios(audios: AnswerAudio[]) {
|
|
77
|
+
if (!audios) {
|
|
78
|
+
console.warn('VoicePlayerModel: audios is not provided')
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
audios.forEach((audio, index) => {
|
|
82
|
+
const attemptNumber = index + 1
|
|
83
|
+
if (!audio.audioFileId) {
|
|
84
|
+
console.warn('VoicePlayerModel: audioFileId is missing for audio', audio)
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
this.collection.add(attemptNumber, {
|
|
88
|
+
attemptNumber,
|
|
89
|
+
audioFileId: audio.audioFileId,
|
|
90
|
+
_id: audio._id,
|
|
91
|
+
hasDrawing: !!audio.drawing,
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private releaseCollectionResources() {
|
|
97
|
+
this.collection.getAll().forEach((item) => {
|
|
98
|
+
if (item.controller) {
|
|
99
|
+
this.downloader.abortDownload(item.controller)
|
|
100
|
+
}
|
|
101
|
+
if (item.audioUri?.startsWith('blob:')) {
|
|
102
|
+
try {
|
|
103
|
+
URL.revokeObjectURL(item.audioUri)
|
|
104
|
+
} catch (e) {}
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private abortAllDownloads() {
|
|
110
|
+
this.collection.getAll().forEach((item) => {
|
|
111
|
+
if (item.controller && item.audioLoading) {
|
|
112
|
+
this.downloader.abortDownload(item.controller)
|
|
113
|
+
this.collection.update(item.attemptNumber, {
|
|
114
|
+
audioLoading: false,
|
|
115
|
+
controller: undefined,
|
|
116
|
+
audioDownloadPromise: undefined,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private readonly handlePlayAttempt = createEffect(async (attemptNumber: number) => {
|
|
123
|
+
this.shouldPreventPlayback = false
|
|
124
|
+
const item = this.collection.get(attemptNumber)
|
|
125
|
+
if (!item) return
|
|
126
|
+
|
|
127
|
+
if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
|
|
128
|
+
this.abortAllDownloads()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (this.collection.hasAudio(attemptNumber)) {
|
|
132
|
+
this.playAudioFx(attemptNumber)
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
this.playerModel.setPlayerState(PlayerState.LOADING)
|
|
138
|
+
const { collectionItem, downloadPromise } = await this.downloader.download({
|
|
139
|
+
audioFileId: item.audioFileId,
|
|
140
|
+
attemptNumber,
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
if (this.shouldPreventPlayback) {
|
|
144
|
+
collectionItem.controller?.abort()
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.collection.update(attemptNumber, collectionItem)
|
|
149
|
+
|
|
150
|
+
const result = await downloadPromise
|
|
151
|
+
|
|
152
|
+
if (this.shouldPreventPlayback) {
|
|
153
|
+
if (result.uri?.startsWith('blob:')) {
|
|
154
|
+
URL.revokeObjectURL(result.uri)
|
|
155
|
+
}
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
this.collection.update(attemptNumber, {
|
|
160
|
+
audioUri: result.uri,
|
|
161
|
+
audioLoading: false,
|
|
162
|
+
audioError: undefined,
|
|
163
|
+
controller: undefined,
|
|
164
|
+
audioDownloadPromise: undefined,
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
this.playerModel.setPlayerState(PlayerState.IDLE)
|
|
168
|
+
this.playAudioFx(attemptNumber)
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.error('Audio download error:', error)
|
|
171
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
172
|
+
this.playerModel.setPlayerState(PlayerState.IDLE)
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this.collection.update(attemptNumber, {
|
|
177
|
+
audioLoading: false,
|
|
178
|
+
audioError: error instanceof Error ? error.message : 'Failed to download audio',
|
|
179
|
+
controller: undefined,
|
|
180
|
+
audioDownloadPromise: undefined,
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
private playAudioFx = createEffect(async (attemptNumber: number) => {
|
|
186
|
+
if (this.shouldPreventPlayback) return
|
|
187
|
+
|
|
188
|
+
const item = this.collection.get(attemptNumber)
|
|
189
|
+
if (!item?.audioUri) {
|
|
190
|
+
console.warn('No audio URI available for attempt:', attemptNumber)
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
|
|
196
|
+
this.playerModel.player?.remove()
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (this.currentPlayingAttempt === attemptNumber && this.playerModel.player?.playing) {
|
|
200
|
+
this.playerModel.pause()
|
|
201
|
+
return
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (this.currentPlayingAttempt === attemptNumber && !this.playerModel.player?.playing) {
|
|
205
|
+
this.playerModel.resume()
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
this.currentPlayingAttempt = attemptNumber
|
|
210
|
+
this.setCurrentAttempt(attemptNumber)
|
|
211
|
+
await this.playerModel.play(item.audioUri)
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error('Error playing audio:', error)
|
|
214
|
+
this.playerModel.setPlayerState(PlayerState.IDLE)
|
|
215
|
+
|
|
216
|
+
this.collection.update(attemptNumber, {
|
|
217
|
+
audioError: error instanceof Error ? error.message : 'Failed to play audio',
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
public isAudioLoading(attemptNumber: number): boolean {
|
|
223
|
+
return this.collection.get(attemptNumber)?.audioLoading || false
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
public getAllAttempts(): VoiceTranscriptionItem[] {
|
|
227
|
+
return this.collection.getAll()
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
public reinitializePlayer() {
|
|
231
|
+
this.playerModel.reinitialize()
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public cleanup() {
|
|
235
|
+
this.releaseCollectionResources()
|
|
236
|
+
this.collection.clear()
|
|
237
|
+
this.currentPlayingAttempt = null
|
|
238
|
+
this.reset()
|
|
239
|
+
this.loader.reset()
|
|
240
|
+
this.dropdown.reset()
|
|
241
|
+
this.playerModel.release()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public togglePlayPause = attach({
|
|
245
|
+
source: this.playerModel.$playerState,
|
|
246
|
+
mapParams: (attemptNumber: number, playerState) => ({ attemptNumber, playerState }),
|
|
247
|
+
effect: createEffect(({ attemptNumber, playerState }: TogglePlayPauseParams) => {
|
|
248
|
+
if (this.currentPlayingAttempt === attemptNumber && playerState === PlayerState.PLAYING) {
|
|
249
|
+
this.pauseAudio()
|
|
250
|
+
} else {
|
|
251
|
+
this.handlePlayAttempt(attemptNumber)
|
|
252
|
+
}
|
|
253
|
+
}),
|
|
254
|
+
})
|
|
255
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { VoiceTranscriptionItem } from '../../types'
|
|
2
|
+
|
|
3
|
+
export class VoiceTranscriptionsCollection {
|
|
4
|
+
public readonly collection: Map<number, VoiceTranscriptionItem> = new Map()
|
|
5
|
+
|
|
6
|
+
public add(attemptNumber: number, item: VoiceTranscriptionItem) {
|
|
7
|
+
this.collection.set(attemptNumber, item)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public update(attemptNumber: number, item: Partial<VoiceTranscriptionItem>) {
|
|
11
|
+
const existingItem = this.collection.get(attemptNumber) || ({} as VoiceTranscriptionItem)
|
|
12
|
+
this.collection.set(attemptNumber, { ...existingItem, ...item })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public delete(attemptNumber: number) {
|
|
16
|
+
this.collection.delete(attemptNumber)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public get(attemptNumber: number) {
|
|
20
|
+
return this.collection.get(attemptNumber)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getAll() {
|
|
24
|
+
return Array.from(this.collection.values())
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public clear() {
|
|
28
|
+
this.collection.clear()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public hasTranscript(attemptNumber: number) {
|
|
32
|
+
const item = this.collection.get(attemptNumber)
|
|
33
|
+
return !!item?.transcript
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public hasAudio(attemptNumber: number) {
|
|
37
|
+
const item = this.collection.get(attemptNumber)
|
|
38
|
+
return !!item?.audioUri
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createEvent, createStore, restore } from 'effector'
|
|
2
|
+
|
|
3
|
+
export class VoiceTranscriptionsDropdownModel {
|
|
4
|
+
public readonly toggleExpand = createEvent()
|
|
5
|
+
public readonly setExpanded = createEvent<boolean>()
|
|
6
|
+
public readonly reset = createEvent()
|
|
7
|
+
|
|
8
|
+
public readonly $isExpanded = restore(this.setExpanded, false)
|
|
9
|
+
.on(this.toggleExpand, (state) => !state)
|
|
10
|
+
.reset(this.reset)
|
|
11
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle, StyleSheet } from 'react-native'
|
|
2
|
+
import { VoiceRecordButton } from './VoiceRecordButton'
|
|
3
|
+
import React, { useEffect } from 'react'
|
|
4
|
+
import { COLORS, SPACING } from '@magmamath/react-native-ui'
|
|
5
|
+
import { VoiceRecordDeleteButton } from './VoiceRecordDeleteButton'
|
|
6
|
+
import { VoiceRecordDivider } from './VoiceRecordDivider'
|
|
7
|
+
import { VoiceRecordTimer } from './VoiceRecordTimer'
|
|
8
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated'
|
|
9
|
+
import { VoiceRecordModel } from '../model/VoiceRecord.model'
|
|
10
|
+
import { useVoiceRecorder } from '../hooks/useVoiceRecorder'
|
|
11
|
+
import { useVoiceRecorderAnimation } from '../hooks/useVoiceRecorderAnimation'
|
|
12
|
+
import { useUnit } from 'effector-react'
|
|
13
|
+
|
|
14
|
+
type VoiceRecordProps = {
|
|
15
|
+
style?: StyleProp<ViewStyle>
|
|
16
|
+
model: VoiceRecordModel
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const VoiceRecord = ({ style, model }: VoiceRecordProps) => {
|
|
20
|
+
const { recorderState } = useVoiceRecorder(model)
|
|
21
|
+
const [isExpanded, isDisabled] = useUnit([model.$isExpanded, model.$isButtonDisabled])
|
|
22
|
+
|
|
23
|
+
const { containerAnimatedStyle } = useVoiceRecorderAnimation(isExpanded)
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
return () => {
|
|
27
|
+
model.cleanup()
|
|
28
|
+
}
|
|
29
|
+
}, [model])
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Animated.View style={[styles.container, style, containerAnimatedStyle]}>
|
|
33
|
+
<VoiceRecordButton model={model} />
|
|
34
|
+
{isExpanded && (
|
|
35
|
+
<Animated.View entering={FadeIn} exiting={FadeOut} style={styles.expendedContainer}>
|
|
36
|
+
<VoiceRecordTimer
|
|
37
|
+
style={styles.timer}
|
|
38
|
+
model={model}
|
|
39
|
+
recordingFileDurationMs={recorderState.durationMillis}
|
|
40
|
+
/>
|
|
41
|
+
<VoiceRecordDivider />
|
|
42
|
+
<VoiceRecordDeleteButton isDisabled={isDisabled} onPress={model.events.deleteRecord} />
|
|
43
|
+
</Animated.View>
|
|
44
|
+
)}
|
|
45
|
+
</Animated.View>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const styles = StyleSheet.create({
|
|
50
|
+
container: {
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
padding: 3,
|
|
53
|
+
paddingBottom: 6,
|
|
54
|
+
backgroundColor: COLORS.NEUTRAL_3,
|
|
55
|
+
borderRadius: 32,
|
|
56
|
+
boxShadow: '0 1px 3px 0 rgba(51, 51, 51, 0.10), 0 0 1px 0 rgba(51, 51, 51, 0.40)',
|
|
57
|
+
overflow: 'hidden',
|
|
58
|
+
},
|
|
59
|
+
timer: {
|
|
60
|
+
marginTop: SPACING[400],
|
|
61
|
+
},
|
|
62
|
+
expendedContainer: {
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
},
|
|
65
|
+
})
|