Media Viewer: Fix document and shared media preview
This commit is contained in:
parent
7f3637f68b
commit
e07b7ca0d3
@ -114,15 +114,14 @@ const MediaViewer: FC<StateProps> = ({
|
|||||||
isVideo,
|
isVideo,
|
||||||
isPhoto,
|
isPhoto,
|
||||||
bestImageData,
|
bestImageData,
|
||||||
|
bestData,
|
||||||
dimensions,
|
dimensions,
|
||||||
isGif,
|
isGif,
|
||||||
isFromSharedMedia,
|
isFromSharedMedia,
|
||||||
avatarPhoto,
|
avatarPhoto,
|
||||||
fileName,
|
fileName,
|
||||||
fullMediaBlobUrl,
|
|
||||||
previewBlobUrl,
|
|
||||||
} = useMediaProps({
|
} = useMediaProps({
|
||||||
message, avatarOwner, mediaId, delay: isGhostAnimation && ANIMATION_DURATION,
|
message, avatarOwner, mediaId, origin, delay: isGhostAnimation && ANIMATION_DURATION,
|
||||||
});
|
});
|
||||||
|
|
||||||
const canReport = !!avatarPhoto && !isChatWithSelf;
|
const canReport = !!avatarPhoto && !isChatWithSelf;
|
||||||
@ -244,7 +243,7 @@ const MediaViewer: FC<StateProps> = ({
|
|||||||
threadId,
|
threadId,
|
||||||
mediaId: id,
|
mediaId: id,
|
||||||
avatarOwnerId: avatarOwner?.id,
|
avatarOwnerId: avatarOwner?.id,
|
||||||
origin,
|
origin: origin!,
|
||||||
}, {
|
}, {
|
||||||
forceOnHeavyAnimation: true,
|
forceOnHeavyAnimation: true,
|
||||||
});
|
});
|
||||||
@ -334,7 +333,7 @@ const MediaViewer: FC<StateProps> = ({
|
|||||||
{renderSenderInfo()}
|
{renderSenderInfo()}
|
||||||
</Transition>
|
</Transition>
|
||||||
<MediaViewerActions
|
<MediaViewerActions
|
||||||
mediaData={fullMediaBlobUrl || previewBlobUrl}
|
mediaData={bestData}
|
||||||
isVideo={isVideo}
|
isVideo={isVideo}
|
||||||
message={message}
|
message={message}
|
||||||
canDeleteAvatar={canDeleteMedia && !!avatarPhoto}
|
canDeleteAvatar={canDeleteMedia && !!avatarPhoto}
|
||||||
|
|||||||
@ -83,13 +83,10 @@ const MediaViewerContent: FC<OwnProps & StateProps> = (props) => {
|
|||||||
isVideo,
|
isVideo,
|
||||||
isPhoto,
|
isPhoto,
|
||||||
bestImageData,
|
bestImageData,
|
||||||
|
bestData,
|
||||||
dimensions,
|
dimensions,
|
||||||
isGif,
|
isGif,
|
||||||
isVideoAvatar,
|
isVideoAvatar,
|
||||||
localBlobUrl,
|
|
||||||
fullMediaBlobUrl,
|
|
||||||
previewBlobUrl,
|
|
||||||
pictogramBlobUrl,
|
|
||||||
videoSize,
|
videoSize,
|
||||||
loadProgress,
|
loadProgress,
|
||||||
} = useMediaProps({
|
} = useMediaProps({
|
||||||
@ -107,7 +104,7 @@ const MediaViewerContent: FC<OwnProps & StateProps> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<div key={chatId} className="MediaViewerContent">
|
<div key={chatId} className="MediaViewerContent">
|
||||||
{renderPhoto(
|
{renderPhoto(
|
||||||
fullMediaBlobUrl || previewBlobUrl,
|
bestData,
|
||||||
calculateMediaViewerDimensions(dimensions, false),
|
calculateMediaViewerDimensions(dimensions, false),
|
||||||
!IS_SINGLE_COLUMN_LAYOUT && !isProtected,
|
!IS_SINGLE_COLUMN_LAYOUT && !isProtected,
|
||||||
isProtected,
|
isProtected,
|
||||||
@ -119,7 +116,7 @@ const MediaViewerContent: FC<OwnProps & StateProps> = (props) => {
|
|||||||
<div key={chatId} className="MediaViewerContent">
|
<div key={chatId} className="MediaViewerContent">
|
||||||
<VideoPlayer
|
<VideoPlayer
|
||||||
key={mediaId}
|
key={mediaId}
|
||||||
url={localBlobUrl || fullMediaBlobUrl}
|
url={bestData}
|
||||||
isGif
|
isGif
|
||||||
posterData={bestImageData}
|
posterData={bestImageData}
|
||||||
posterSize={calculateMediaViewerDimensions(dimensions!, false, true)}
|
posterSize={calculateMediaViewerDimensions(dimensions!, false, true)}
|
||||||
@ -151,7 +148,7 @@ const MediaViewerContent: FC<OwnProps & StateProps> = (props) => {
|
|||||||
className={buildClassName('MediaViewerContent', hasFooter && 'has-footer')}
|
className={buildClassName('MediaViewerContent', hasFooter && 'has-footer')}
|
||||||
>
|
>
|
||||||
{isPhoto && renderPhoto(
|
{isPhoto && renderPhoto(
|
||||||
localBlobUrl || fullMediaBlobUrl || previewBlobUrl || pictogramBlobUrl,
|
bestData,
|
||||||
message && calculateMediaViewerDimensions(dimensions!, hasFooter),
|
message && calculateMediaViewerDimensions(dimensions!, hasFooter),
|
||||||
!IS_SINGLE_COLUMN_LAYOUT && !isProtected,
|
!IS_SINGLE_COLUMN_LAYOUT && !isProtected,
|
||||||
isProtected,
|
isProtected,
|
||||||
@ -164,7 +161,7 @@ const MediaViewerContent: FC<OwnProps & StateProps> = (props) => {
|
|||||||
) : (
|
) : (
|
||||||
<VideoPlayer
|
<VideoPlayer
|
||||||
key={mediaId}
|
key={mediaId}
|
||||||
url={localBlobUrl || fullMediaBlobUrl}
|
url={bestData}
|
||||||
isGif={isGif}
|
isGif={isGif}
|
||||||
posterData={bestImageData}
|
posterData={bestImageData}
|
||||||
posterSize={message && calculateMediaViewerDimensions(dimensions!, hasFooter, true)}
|
posterSize={message && calculateMediaViewerDimensions(dimensions!, hasFooter, true)}
|
||||||
|
|||||||
@ -77,7 +77,10 @@ export const useMediaProps = ({
|
|||||||
}, [avatarOwner, message, avatarMedia, mediaId]);
|
}, [avatarOwner, message, avatarMedia, mediaId]);
|
||||||
|
|
||||||
const pictogramBlobUrl = useMedia(
|
const pictogramBlobUrl = useMedia(
|
||||||
message && (isFromSharedMedia || isFromSearch) && getMessageMediaHash(message, 'pictogram'),
|
message
|
||||||
|
// Only use pictogram if it's already loaded
|
||||||
|
&& (isFromSharedMedia || isFromSearch || isDocumentPhoto || isDocumentVideo)
|
||||||
|
&& getMessageMediaHash(message, 'pictogram'),
|
||||||
undefined,
|
undefined,
|
||||||
ApiMediaFormat.BlobUrl,
|
ApiMediaFormat.BlobUrl,
|
||||||
undefined,
|
undefined,
|
||||||
@ -111,6 +114,9 @@ export const useMediaProps = ({
|
|||||||
if (isVideoAvatar && previewBlobUrl) {
|
if (isVideoAvatar && previewBlobUrl) {
|
||||||
bestImageData = previewBlobUrl;
|
bestImageData = previewBlobUrl;
|
||||||
}
|
}
|
||||||
|
const bestData = localBlobUrl || fullMediaBlobUrl || (
|
||||||
|
!isVideo ? previewBlobUrl || pictogramBlobUrl || bestImageData : undefined
|
||||||
|
);
|
||||||
|
|
||||||
const fileName = message
|
const fileName = message
|
||||||
? getMessageFileName(message)
|
? getMessageFileName(message)
|
||||||
@ -144,14 +150,11 @@ export const useMediaProps = ({
|
|||||||
isDocumentVideo,
|
isDocumentVideo,
|
||||||
fileName,
|
fileName,
|
||||||
bestImageData,
|
bestImageData,
|
||||||
|
bestData,
|
||||||
dimensions,
|
dimensions,
|
||||||
isFromSharedMedia,
|
isFromSharedMedia,
|
||||||
avatarPhoto: avatarMedia,
|
avatarPhoto: avatarMedia,
|
||||||
isVideoAvatar,
|
isVideoAvatar,
|
||||||
localBlobUrl,
|
|
||||||
fullMediaBlobUrl,
|
|
||||||
previewBlobUrl,
|
|
||||||
pictogramBlobUrl,
|
|
||||||
loadProgress,
|
loadProgress,
|
||||||
videoSize,
|
videoSize,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -212,7 +212,7 @@ export function getMessageMediaHash(
|
|||||||
return `${base}?size=x`;
|
return `${base}?size=x`;
|
||||||
case 'full':
|
case 'full':
|
||||||
case 'download':
|
case 'download':
|
||||||
return `${base}?size=z`;
|
return document ? base : `${base}?size=z`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -808,7 +808,7 @@ export interface ActionPayloads {
|
|||||||
mediaId?: number;
|
mediaId?: number;
|
||||||
avatarOwnerId?: string;
|
avatarOwnerId?: string;
|
||||||
profilePhotoIndex?: number;
|
profilePhotoIndex?: number;
|
||||||
origin?: MediaViewerOrigin;
|
origin: MediaViewerOrigin;
|
||||||
volume?: number;
|
volume?: number;
|
||||||
playbackRate?: number;
|
playbackRate?: number;
|
||||||
isMuted?: boolean;
|
isMuted?: boolean;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user