Paid media: Follow up (#4797)
This commit is contained in:
parent
48e8bf6dda
commit
490a98be8b
@ -6,7 +6,6 @@ import { getActions } from '../../global';
|
|||||||
import type { ApiDocument, ApiMessage } from '../../api/types';
|
import type { ApiDocument, ApiMessage } from '../../api/types';
|
||||||
import type { ObserveFn } from '../../hooks/useIntersectionObserver';
|
import type { ObserveFn } from '../../hooks/useIntersectionObserver';
|
||||||
|
|
||||||
import { SUPPORTED_IMAGE_CONTENT_TYPES, SUPPORTED_VIDEO_CONTENT_TYPES } from '../../config';
|
|
||||||
import {
|
import {
|
||||||
getDocumentMediaHash,
|
getDocumentMediaHash,
|
||||||
getMediaFormat,
|
getMediaFormat,
|
||||||
@ -121,9 +120,7 @@ const Document = ({
|
|||||||
const localBlobUrl = hasPreview ? document.previewBlobUrl : undefined;
|
const localBlobUrl = hasPreview ? document.previewBlobUrl : undefined;
|
||||||
const previewData = useMedia(getDocumentMediaHash(document, 'pictogram'), !isIntersecting);
|
const previewData = useMedia(getDocumentMediaHash(document, 'pictogram'), !isIntersecting);
|
||||||
|
|
||||||
const withMediaViewer = onMediaClick && Boolean(document.mediaType) && (
|
const withMediaViewer = onMediaClick && document.innerMediaType;
|
||||||
SUPPORTED_VIDEO_CONTENT_TYPES.has(document.mimeType) || SUPPORTED_IMAGE_CONTENT_TYPES.has(document.mimeType)
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleDownload = useLastCallback(() => {
|
const handleDownload = useLastCallback(() => {
|
||||||
downloadMedia({ media: document });
|
downloadMedia({ media: document });
|
||||||
|
|||||||
@ -97,7 +97,7 @@ const MediaViewerContent = ({
|
|||||||
|
|
||||||
if (!media) return undefined;
|
if (!media) return undefined;
|
||||||
|
|
||||||
if (item.type !== 'message') {
|
if (item.type === 'avatar') {
|
||||||
if (!isVideoAvatar) {
|
if (!isVideoAvatar) {
|
||||||
return (
|
return (
|
||||||
<div key={media.id} className="MediaViewerContent">
|
<div key={media.id} className="MediaViewerContent">
|
||||||
@ -136,10 +136,9 @@ const MediaViewerContent = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!textMessage) return undefined;
|
const textParts = textMessage && (textMessage.content.action?.type === 'suggestProfilePhoto'
|
||||||
const textParts = textMessage.content.action?.type === 'suggestProfilePhoto'
|
|
||||||
? lang('Conversation.SuggestedPhotoTitle')
|
? lang('Conversation.SuggestedPhotoTitle')
|
||||||
: renderMessageText({ message: textMessage, forcePlayback: true, isForMediaViewer: true });
|
: renderMessageText({ message: textMessage, forcePlayback: true, isForMediaViewer: true }));
|
||||||
|
|
||||||
const hasFooter = Boolean(textParts);
|
const hasFooter = Boolean(textParts);
|
||||||
const posterSize = calculateMediaViewerDimensions(dimensions!, hasFooter, isVideo);
|
const posterSize = calculateMediaViewerDimensions(dimensions!, hasFooter, isVideo);
|
||||||
|
|||||||
@ -91,7 +91,6 @@ export default function getViewableMedia(params?: MediaViewerItem): ViewableMedi
|
|||||||
if (document && (isDocumentPhoto(document) || isDocumentVideo(document))) {
|
if (document && (isDocumentPhoto(document) || isDocumentVideo(document))) {
|
||||||
return {
|
return {
|
||||||
media: document,
|
media: document,
|
||||||
isSingle: true,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,8 @@ import useBlurSync from '../../../hooks/useBlurSync';
|
|||||||
import useMedia from '../../../hooks/useMedia';
|
import useMedia from '../../../hooks/useMedia';
|
||||||
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
||||||
|
|
||||||
|
const FALLBACK_DIMENSIONS = AVATAR_FULL_DIMENSIONS;
|
||||||
|
|
||||||
type UseMediaProps = {
|
type UseMediaProps = {
|
||||||
media?: MediaViewerMedia;
|
media?: MediaViewerMedia;
|
||||||
isAvatar?: boolean;
|
isAvatar?: boolean;
|
||||||
@ -111,7 +113,8 @@ export const useMediaProps = ({
|
|||||||
if (isVideo) {
|
if (isVideo) {
|
||||||
return getVideoDimensions(media);
|
return getVideoDimensions(media);
|
||||||
}
|
}
|
||||||
return undefined;
|
|
||||||
|
return FALLBACK_DIMENSIONS;
|
||||||
}, [isAvatar, isDocument, isPhoto, isVideo, isVideoAvatar, media]);
|
}, [isAvatar, isDocument, isPhoto, isVideo, isVideoAvatar, media]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -22,6 +22,10 @@
|
|||||||
margin: 0 0 0.3125rem;
|
margin: 0 0 0.3125rem;
|
||||||
--border-bottom-left-radius: inherit;
|
--border-bottom-left-radius: inherit;
|
||||||
--border-bottom-right-radius: inherit;
|
--border-bottom-right-radius: inherit;
|
||||||
|
|
||||||
|
+ .message-paid-media-status {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
|
|
||||||
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.boughtStatus {
|
.boughtStatus {
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.preview {
|
.preview {
|
||||||
height: 2.5rem;
|
height: 3rem;
|
||||||
width: 2.5rem;
|
width: 3rem;
|
||||||
|
|
||||||
grid-auto-columns: 0.25rem;
|
grid-auto-columns: 0.25rem;
|
||||||
grid-auto-rows: 0.25rem;
|
grid-auto-rows: 0.25rem;
|
||||||
|
|||||||
@ -178,6 +178,7 @@
|
|||||||
|
|
||||||
.stackedStar {
|
.stackedStar {
|
||||||
@include mixins.filter-outline(0.0625rem, var(--_background-color));
|
@include mixins.filter-outline(0.0625rem, var(--_background-color));
|
||||||
|
transition: filter 0.25s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.optionBottom {
|
.optionBottom {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { TeactNode } from '../../lib/teact/teact';
|
import type { TeactNode } from '../../lib/teact/teact';
|
||||||
|
|
||||||
import type { ApiMessage, MediaContent } from '../../api/types';
|
import type { ApiMediaExtendedPreview, ApiMessage, MediaContent } from '../../api/types';
|
||||||
import type { LangFn } from '../../hooks/useOldLang';
|
import type { LangFn } from '../../hooks/useOldLang';
|
||||||
import { ApiMessageEntityTypes } from '../../api/types';
|
import { ApiMessageEntityTypes } from '../../api/types';
|
||||||
|
|
||||||
@ -70,9 +70,10 @@ export function getMessageSummaryEmoji(message: ApiMessage) {
|
|||||||
document,
|
document,
|
||||||
sticker,
|
sticker,
|
||||||
poll,
|
poll,
|
||||||
|
paidMedia,
|
||||||
} = message.content;
|
} = message.content;
|
||||||
|
|
||||||
if (message.groupedId || photo) {
|
if (message.groupedId || photo || paidMedia) {
|
||||||
return '🖼';
|
return '🖼';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,24 +138,34 @@ function getSummaryDescription(
|
|||||||
storyData,
|
storyData,
|
||||||
giveaway,
|
giveaway,
|
||||||
giveawayResults,
|
giveawayResults,
|
||||||
|
paidMedia,
|
||||||
} = mediaContent;
|
} = mediaContent;
|
||||||
|
|
||||||
let hasUsedTruncatedText = false;
|
let hasUsedTruncatedText = false;
|
||||||
let summary: string | TeactNode | undefined;
|
let summary: string | TeactNode | undefined;
|
||||||
|
|
||||||
if (message?.groupedId) {
|
const boughtExtendedMedia = paidMedia?.isBought && paidMedia.extendedMedia;
|
||||||
|
const previewExtendedMedia = paidMedia && !paidMedia.isBought
|
||||||
|
? paidMedia.extendedMedia as ApiMediaExtendedPreview[] : undefined;
|
||||||
|
|
||||||
|
const isPaidMediaAlbum = paidMedia && paidMedia.extendedMedia.length > 1;
|
||||||
|
const isPaidMediaSingleVideo = !isPaidMediaAlbum
|
||||||
|
&& (boughtExtendedMedia?.[0].video || previewExtendedMedia?.[0].duration);
|
||||||
|
const isPaidMediaSinglePhoto = !isPaidMediaAlbum && !isPaidMediaSingleVideo;
|
||||||
|
|
||||||
|
if (message?.groupedId || isPaidMediaAlbum) {
|
||||||
hasUsedTruncatedText = true;
|
hasUsedTruncatedText = true;
|
||||||
summary = truncatedText || lang('lng_in_dlg_album');
|
summary = truncatedText || lang('lng_in_dlg_album');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (photo) {
|
if (photo || isPaidMediaSinglePhoto) {
|
||||||
hasUsedTruncatedText = true;
|
hasUsedTruncatedText = true;
|
||||||
summary = truncatedText || lang('AttachPhoto');
|
summary = truncatedText || lang('AttachPhoto');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video) {
|
if (video || isPaidMediaSingleVideo) {
|
||||||
hasUsedTruncatedText = true;
|
hasUsedTruncatedText = true;
|
||||||
summary = truncatedText || lang(video.isGif ? 'AttachGif' : 'AttachVideo');
|
summary = truncatedText || lang(video?.isGif ? 'AttachGif' : 'AttachVideo');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sticker) {
|
if (sticker) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user