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