2021-03-24 22:06:12 +00:00
|
|
|
// 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';
|
|
|
|
|
2021-04-15 21:02:24 +00:00
|
|
|
type AudioAttachmentProps = Omit<MessageAudioProps, 'audio' | 'computePeaks'>;
|
2021-03-24 22:06:12 +00:00
|
|
|
|
|
|
|
export function renderAudioAttachment(
|
|
|
|
props: AudioAttachmentProps
|
|
|
|
): ReactElement {
|
|
|
|
return (
|
|
|
|
<GlobalAudioContext.Consumer>
|
|
|
|
{globalAudioProps => {
|
|
|
|
return (
|
|
|
|
globalAudioProps && (
|
|
|
|
<SmartMessageAudio {...props} {...globalAudioProps} />
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
</GlobalAudioContext.Consumer>
|
|
|
|
);
|
|
|
|
}
|