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