2023-01-03 11:55:46 -08:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-03-24 17:06:12 -05:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { ReactElement } from 'react';
|
|
|
|
import React from 'react';
|
2023-02-24 16:18:57 -07:00
|
|
|
import { VoiceNotesPlaybackContext } from '../../components/VoiceNotesPlaybackContext';
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { Props as MessageAudioProps } from './MessageAudio';
|
|
|
|
import { SmartMessageAudio } from './MessageAudio';
|
2021-03-24 17:06:12 -05:00
|
|
|
|
2022-11-04 07:22:07 -06:00
|
|
|
type AudioAttachmentProps = Omit<MessageAudioProps, 'computePeaks'>;
|
2021-03-24 17:06:12 -05:00
|
|
|
|
|
|
|
export function renderAudioAttachment(
|
|
|
|
props: AudioAttachmentProps
|
|
|
|
): ReactElement {
|
|
|
|
return (
|
2023-02-24 16:18:57 -07:00
|
|
|
<VoiceNotesPlaybackContext.Consumer>
|
|
|
|
{voiceNotesPlaybackProps => {
|
2021-03-24 17:06:12 -05:00
|
|
|
return (
|
2023-02-24 16:18:57 -07:00
|
|
|
voiceNotesPlaybackProps && (
|
|
|
|
<SmartMessageAudio {...props} {...voiceNotesPlaybackProps} />
|
2021-03-24 17:06:12 -05:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}}
|
2023-02-24 16:18:57 -07:00
|
|
|
</VoiceNotesPlaybackContext.Consumer>
|
2021-03-24 17:06:12 -05:00
|
|
|
);
|
|
|
|
}
|