0b969f3f42
There are two parts to this change: 1. The computation of peaks is moved from `MessageAudio` to the `GlobalAudioContext` and thus we can limit the concurrency of the computations (`p-queue`!) and de-duplicate the computations as well 2. While the peaks are computed the component has to display spinning animation instead of empty waveform and unclickable UI.
24 lines
714 B
TypeScript
24 lines
714 B
TypeScript
// Copyright 2021 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import React, { ReactElement } from 'react';
|
|
import { GlobalAudioContext } from '../../components/GlobalAudioContext';
|
|
import { SmartMessageAudio, Props as MessageAudioProps } from './MessageAudio';
|
|
|
|
type AudioAttachmentProps = Omit<MessageAudioProps, 'audio' | 'computePeaks'>;
|
|
|
|
export function renderAudioAttachment(
|
|
props: AudioAttachmentProps
|
|
): ReactElement {
|
|
return (
|
|
<GlobalAudioContext.Consumer>
|
|
{globalAudioProps => {
|
|
return (
|
|
globalAudioProps && (
|
|
<SmartMessageAudio {...props} {...globalAudioProps} />
|
|
)
|
|
);
|
|
}}
|
|
</GlobalAudioContext.Consumer>
|
|
);
|
|
}
|