Bot Info: Fix image size on high DPI screens (#4896)
This commit is contained in:
parent
383a2d50b2
commit
489d92dd1c
@ -17,7 +17,6 @@ import renderText from '../common/helpers/renderText';
|
||||
|
||||
import useMedia from '../../hooks/useMedia';
|
||||
import useOldLang from '../../hooks/useOldLang';
|
||||
import useDevicePixelRatio from '../../hooks/window/useDevicePixelRatio';
|
||||
|
||||
import OptimizedVideo from '../ui/OptimizedVideo';
|
||||
import Skeleton from '../ui/placeholder/Skeleton';
|
||||
@ -40,19 +39,14 @@ const MessageListBotInfo: FC<OwnProps & StateProps> = ({
|
||||
isInMessageList,
|
||||
}) => {
|
||||
const lang = useOldLang();
|
||||
const dpr = useDevicePixelRatio();
|
||||
|
||||
const botInfoPhotoUrl = useMedia(botInfo?.photo ? getBotCoverMediaHash(botInfo.photo) : undefined);
|
||||
const botInfoGifUrl = useMedia(botInfo?.gif ? getVideoMediaHash(botInfo.gif, 'full') : undefined);
|
||||
const botInfoDimensions = botInfo?.photo ? getPhotoFullDimensions(botInfo.photo) : botInfo?.gif
|
||||
? getVideoDimensions(botInfo.gif) : undefined;
|
||||
const botInfoRealDimensions = botInfoDimensions && {
|
||||
width: botInfoDimensions.width / dpr,
|
||||
height: botInfoDimensions.height / dpr,
|
||||
};
|
||||
const isBotInfoEmpty = botInfo && !botInfo.description && !botInfo.gif && !botInfo.photo;
|
||||
|
||||
const { width, height } = botInfoRealDimensions || {};
|
||||
const { width, height } = botInfoDimensions || {};
|
||||
|
||||
const isEmptyOrLoading = isBotInfoEmpty || isLoadingBotInfo;
|
||||
|
||||
@ -65,16 +59,16 @@ const MessageListBotInfo: FC<OwnProps & StateProps> = ({
|
||||
{botInfo && (
|
||||
<div
|
||||
className={styles.botInfo}
|
||||
style={botInfoRealDimensions && (
|
||||
`width: ${botInfoRealDimensions.width}px`
|
||||
style={buildStyle(
|
||||
width ? `width: ${width}px` : undefined,
|
||||
)}
|
||||
>
|
||||
{botInfoPhotoUrl && (
|
||||
<img
|
||||
className={styles.media}
|
||||
src={botInfoPhotoUrl}
|
||||
width={botInfoRealDimensions?.width}
|
||||
height={botInfoRealDimensions?.height}
|
||||
width={width}
|
||||
height={height}
|
||||
alt="Bot info"
|
||||
/>
|
||||
)}
|
||||
@ -93,8 +87,8 @@ const MessageListBotInfo: FC<OwnProps & StateProps> = ({
|
||||
{botInfoDimensions && !botInfoPhotoUrl && !botInfoGifUrl && (
|
||||
<Skeleton
|
||||
className={styles.media}
|
||||
width={botInfoRealDimensions?.width}
|
||||
height={botInfoRealDimensions?.height}
|
||||
width={width}
|
||||
height={height}
|
||||
forceAspectRatio
|
||||
/>
|
||||
)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user