Profile: Fix undefined media in the Voice tab (#4952)

This commit is contained in:
Alexander Zinchuk 2024-09-06 15:43:32 +02:00
parent b611bc409f
commit 13c6e1ab60

View File

@ -32,6 +32,7 @@ import {
getIsDownloading,
getIsSavedDialog,
getMessageDocument,
getMessageDownloadableMedia,
isChatAdmin,
isChatChannel,
isChatGroup,
@ -584,7 +585,11 @@ const Profile: FC<OwnProps & StateProps> = ({
/>
))
) : resultType === 'voice' ? (
(viewportIds as number[])!.map((id) => messagesById[id] && (
(viewportIds as number[])!.map((id) => {
const message = messagesById[id];
if (!message) return undefined;
const media = messagesById[id] && getMessageDownloadableMedia(message)!;
return messagesById[id] && (
<Audio
key={id}
theme={theme}
@ -596,9 +601,10 @@ const Profile: FC<OwnProps & StateProps> = ({
onPlay={handlePlayAudio}
onDateClick={handleMessageFocus}
canDownload={!isChatProtected && !messagesById[id].isProtected}
isDownloading={getIsDownloading(activeDownloads, messagesById[id].content.voice!)}
isDownloading={getIsDownloading(activeDownloads, media)}
/>
))
);
})
) : resultType === 'members' ? (
(viewportIds as string[])!.map((id, i) => (
<ListItem