mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-11 04:58:51 +01:00
* fix: Add null check for SelectedTTS in MessageAudio component to prevent rendering issues * fix: image download browser compatibility with error handling and fallback mechanism - Updated the downloadImage function to use fetch for improved reliability and added error handling. - Implemented a fallback to the original download method in case of fetch failure. - Ensured the download link uses a blob URL for better compatibility with various image types.
23 lines
643 B
TypeScript
23 lines
643 B
TypeScript
import { memo } from 'react';
|
|
import { useRecoilValue } from 'recoil';
|
|
import type { TMessageAudio } from '~/common';
|
|
import { BrowserTTS, ExternalTTS } from '~/components/Audio/TTS';
|
|
import { TTSEndpoints } from '~/common';
|
|
import store from '~/store';
|
|
|
|
function MessageAudio(props: TMessageAudio) {
|
|
const engineTTS = useRecoilValue<string>(store.engineTTS);
|
|
|
|
const TTSComponents = {
|
|
[TTSEndpoints.browser]: BrowserTTS,
|
|
[TTSEndpoints.external]: ExternalTTS,
|
|
};
|
|
|
|
const SelectedTTS = TTSComponents[engineTTS];
|
|
if (!SelectedTTS) {
|
|
return null;
|
|
}
|
|
return <SelectedTTS {...props} />;
|
|
}
|
|
|
|
export default memo(MessageAudio);
|