diff --git a/ts/components/conversation/MessageAudio.tsx b/ts/components/conversation/MessageAudio.tsx index 8d0ece1ddb..b93c2bc8cc 100644 --- a/ts/components/conversation/MessageAudio.tsx +++ b/ts/components/conversation/MessageAudio.tsx @@ -230,7 +230,6 @@ export const MessageAudio: React.FC = (props: Props) => { // NOTE: Avoid division by zero const [duration, setDuration] = useState(1e-23); - const [isLoading, setIsLoading] = useState(true); const [peaks, setPeaks] = useState>( new Array(PEAK_COUNT).fill(0) ); @@ -248,10 +247,12 @@ export const MessageAudio: React.FC = (props: Props) => { // This effect loads audio file and computes its RMS peak for dispalying the // waveform. useEffect(() => { - if (!isLoading || state !== State.Normal) { + if (state !== State.Normal) { return noop; } + window.log.info('MessageAudio: loading audio and computing waveform'); + let canceled = false; (async () => { @@ -275,25 +276,13 @@ export const MessageAudio: React.FC = (props: Props) => { setDuration(Math.max(newDuration, 1e-23)); } catch (err) { window.log.error('MessageAudio: loadAudio error', err); - } finally { - if (!canceled) { - setIsLoading(false); - } } })(); return () => { canceled = true; }; - }, [ - attachment, - audioContext, - isLoading, - setDuration, - setPeaks, - state, - waveformCache, - ]); + }, [attachment, audioContext, setDuration, setPeaks, state, waveformCache]); // This effect attaches/detaches event listeners to the global