Avatar: Hide "Report" button for personal photos (#5060)
This commit is contained in:
parent
2bf42b4d44
commit
0f2fb74621
@ -136,7 +136,7 @@ const MediaViewer = ({
|
|||||||
const isGhostAnimation = Boolean(withAnimation && !shouldSkipHistoryAnimations);
|
const isGhostAnimation = Boolean(withAnimation && !shouldSkipHistoryAnimations);
|
||||||
|
|
||||||
/* Controls */
|
/* Controls */
|
||||||
const [isReportModalOpen, openReportModal, closeReportModal] = useFlag();
|
const [isReportAvatarModalOpen, openReportAvatarModal, closeReportAvatarModal] = useFlag();
|
||||||
|
|
||||||
const currentItem = getMediaViewerItem({
|
const currentItem = getMediaViewerItem({
|
||||||
message, avatarOwner, standaloneMedia, profilePhotos, mediaIndex, sponsoredMessage,
|
message, avatarOwner, standaloneMedia, profilePhotos, mediaIndex, sponsoredMessage,
|
||||||
@ -155,7 +155,13 @@ const MediaViewer = ({
|
|||||||
media, isAvatar: Boolean(avatarOwner), origin, delay: isGhostAnimation && ANIMATION_DURATION,
|
media, isAvatar: Boolean(avatarOwner), origin, delay: isGhostAnimation && ANIMATION_DURATION,
|
||||||
});
|
});
|
||||||
|
|
||||||
const canReport = avatarOwner && !isChatWithSelf;
|
const canReportAvatar = (() => {
|
||||||
|
if (isChatWithSelf) return false;
|
||||||
|
if (currentItem?.type !== 'avatar' || !avatarOwner) return false;
|
||||||
|
const info = currentItem.profilePhotos;
|
||||||
|
if (media === info.personalPhoto) return false;
|
||||||
|
return true;
|
||||||
|
})();
|
||||||
const isVisible = !isHidden && isOpen;
|
const isVisible = !isHidden && isOpen;
|
||||||
|
|
||||||
const messageMediaIds = useMemo(() => {
|
const messageMediaIds = useMemo(() => {
|
||||||
@ -434,15 +440,15 @@ const MediaViewer = ({
|
|||||||
isVideo={isVideo}
|
isVideo={isVideo}
|
||||||
item={currentItem}
|
item={currentItem}
|
||||||
canUpdateMedia={canUpdateMedia}
|
canUpdateMedia={canUpdateMedia}
|
||||||
canReport={canReport}
|
canReportAvatar={canReportAvatar}
|
||||||
onBeforeDelete={handleBeforeDelete}
|
onBeforeDelete={handleBeforeDelete}
|
||||||
onReport={openReportModal}
|
onReportAvatar={openReportAvatarModal}
|
||||||
onCloseMediaViewer={handleClose}
|
onCloseMediaViewer={handleClose}
|
||||||
onForward={handleForward}
|
onForward={handleForward}
|
||||||
/>
|
/>
|
||||||
<ReportModal
|
<ReportModal
|
||||||
isOpen={isReportModalOpen}
|
isOpen={isReportAvatarModalOpen}
|
||||||
onClose={closeReportModal}
|
onClose={closeReportAvatarModal}
|
||||||
subject="media"
|
subject="media"
|
||||||
photo={avatar}
|
photo={avatar}
|
||||||
peerId={avatarOwner?.id}
|
peerId={avatarOwner?.id}
|
||||||
|
|||||||
@ -54,9 +54,9 @@ type OwnProps = {
|
|||||||
mediaData?: string;
|
mediaData?: string;
|
||||||
isVideo: boolean;
|
isVideo: boolean;
|
||||||
canUpdateMedia?: boolean;
|
canUpdateMedia?: boolean;
|
||||||
canReport?: boolean;
|
canReportAvatar?: boolean;
|
||||||
activeDownloads?: ActiveDownloads;
|
activeDownloads?: ActiveDownloads;
|
||||||
onReport: NoneToVoidFunction;
|
onReportAvatar: NoneToVoidFunction;
|
||||||
onBeforeDelete: NoneToVoidFunction;
|
onBeforeDelete: NoneToVoidFunction;
|
||||||
onCloseMediaViewer: NoneToVoidFunction;
|
onCloseMediaViewer: NoneToVoidFunction;
|
||||||
onForward: NoneToVoidFunction;
|
onForward: NoneToVoidFunction;
|
||||||
@ -68,13 +68,13 @@ const MediaViewerActions: FC<OwnProps & StateProps> = ({
|
|||||||
isVideo,
|
isVideo,
|
||||||
isChatProtected,
|
isChatProtected,
|
||||||
isProtected,
|
isProtected,
|
||||||
canReport,
|
canReportAvatar,
|
||||||
canDelete,
|
canDelete,
|
||||||
canUpdate,
|
canUpdate,
|
||||||
messageListType,
|
messageListType,
|
||||||
activeDownloads,
|
activeDownloads,
|
||||||
origin,
|
origin,
|
||||||
onReport,
|
onReportAvatar: onReport,
|
||||||
onCloseMediaViewer,
|
onCloseMediaViewer,
|
||||||
onBeforeDelete,
|
onBeforeDelete,
|
||||||
onForward,
|
onForward,
|
||||||
@ -247,7 +247,7 @@ const MediaViewerActions: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canReport) {
|
if (canReportAvatar) {
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
icon: 'flag',
|
icon: 'flag',
|
||||||
onClick: onReport,
|
onClick: onReport,
|
||||||
@ -335,7 +335,7 @@ const MediaViewerActions: FC<OwnProps & StateProps> = ({
|
|||||||
>
|
>
|
||||||
<i className="icon icon-zoom-in" />
|
<i className="icon icon-zoom-in" />
|
||||||
</Button>
|
</Button>
|
||||||
{canReport && (
|
{canReportAvatar && (
|
||||||
<Button
|
<Button
|
||||||
round
|
round
|
||||||
size="smaller"
|
size="smaller"
|
||||||
|
|||||||
@ -71,13 +71,15 @@ const SenderInfo: FC<OwnProps & StateProps> = ({
|
|||||||
const profilePhotos = item.type === 'avatar' ? item.profilePhotos : undefined;
|
const profilePhotos = item.type === 'avatar' ? item.profilePhotos : undefined;
|
||||||
const avatar = profilePhotos?.photos[item.mediaIndex!];
|
const avatar = profilePhotos?.photos[item.mediaIndex!];
|
||||||
const isFallbackAvatar = avatar?.id === profilePhotos?.fallbackPhoto?.id;
|
const isFallbackAvatar = avatar?.id === profilePhotos?.fallbackPhoto?.id;
|
||||||
|
const isPersonalAvatar = avatar?.id === profilePhotos?.personalPhoto?.id;
|
||||||
const date = item.type === 'message' ? item.message.date : avatar?.date;
|
const date = item.type === 'message' ? item.message.date : avatar?.date;
|
||||||
if (!date) return undefined;
|
if (!date) return undefined;
|
||||||
|
|
||||||
const formattedDate = formatMediaDateTime(lang, date * 1000, true);
|
const formattedDate = formatMediaDateTime(lang, date * 1000, true);
|
||||||
const count = profilePhotos?.count
|
const count = profilePhotos?.count
|
||||||
&& (profilePhotos.count + (profilePhotos?.fallbackPhoto ? 1 : 0));
|
&& (profilePhotos.count + (profilePhotos?.fallbackPhoto ? 1 : 0));
|
||||||
const countText = count && lang('Of', [item.mediaIndex! + 1, count]);
|
const currentIndex = item.mediaIndex! + 1 + (profilePhotos?.personalPhoto ? -1 : 0);
|
||||||
|
const countText = count && lang('Of', [currentIndex, count]);
|
||||||
|
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
if (avatar) {
|
if (avatar) {
|
||||||
@ -85,13 +87,16 @@ const SenderInfo: FC<OwnProps & StateProps> = ({
|
|||||||
const isChannel = chat && isChatChannel(chat);
|
const isChannel = chat && isChatChannel(chat);
|
||||||
const isGroup = chat && isChatGroup(chat);
|
const isGroup = chat && isChatGroup(chat);
|
||||||
parts.push(lang(
|
parts.push(lang(
|
||||||
isFallbackAvatar ? 'lng_mediaview_profile_public_photo'
|
isPersonalAvatar ? 'lng_mediaview_profile_photo_by_you'
|
||||||
: isChannel ? 'lng_mediaview_channel_photo'
|
: isFallbackAvatar ? 'lng_mediaview_profile_public_photo'
|
||||||
: isGroup ? 'lng_mediaview_group_photo' : 'lng_mediaview_profile_photo',
|
: isChannel ? 'lng_mediaview_channel_photo'
|
||||||
|
: isGroup ? 'lng_mediaview_group_photo' : 'lng_mediaview_profile_photo',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (countText) parts.push(countText);
|
if (countText && !isPersonalAvatar && !isFallbackAvatar) {
|
||||||
|
parts.push(countText);
|
||||||
|
}
|
||||||
|
|
||||||
parts.push(formattedDate);
|
parts.push(formattedDate);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user