2021-03-24 22:06:12 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ReactElement } from 'react';
|
|
|
|
import React from 'react';
|
2021-03-24 22:06:12 +00:00
|
|
|
import { GlobalAudioContext } from '../../components/GlobalAudioContext';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { Props as MessageAudioProps } from './MessageAudio';
|
|
|
|
import { SmartMessageAudio } from './MessageAudio';
|
2021-03-24 22:06:12 +00:00
|
|
|
|
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>
|
|
|
|
);
|
|
|
|
}
|