refactor: type cast, remove question marks
This commit is contained in:
parent
45a81a937c
commit
65f03707e4
|
@ -44,7 +44,7 @@ const withinLimits = (aspectRatio: number) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const shouldLetterbox = (attachment: Attachment): boolean => {
|
const shouldLetterbox = (attachment: Attachment): boolean => {
|
||||||
const aspectRatio = 'meta' in attachment && 'original' in attachment.meta && (attachment)?.meta?.original?.aspect;
|
const aspectRatio = 'meta' in attachment && 'original' in attachment.meta && (attachment).meta.original?.aspect;
|
||||||
|
|
||||||
if (!aspectRatio) return true;
|
if (!aspectRatio) return true;
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ const Item: React.FC<IItem> = ({
|
||||||
const attachmentIcon = (
|
const attachmentIcon = (
|
||||||
<SvgIcon
|
<SvgIcon
|
||||||
className={clsx('size-16 text-gray-800 dark:text-gray-200', { 'size-8': compact })}
|
className={clsx('size-16 text-gray-800 dark:text-gray-200', { 'size-8': compact })}
|
||||||
src={MIMETYPE_ICONS[attachment?.pleroma?.mime_type as string] || paperclipIcon}
|
src={MIMETYPE_ICONS[attachment?.pleroma?.mime_type!] || paperclipIcon}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ const MediaGallery: React.FC<IMediaGallery> = (props) => {
|
||||||
|
|
||||||
const getSizeDataSingle = (): SizeData => {
|
const getSizeDataSingle = (): SizeData => {
|
||||||
const w = width || defaultWidth;
|
const w = width || defaultWidth;
|
||||||
const aspectRatio = 'meta' in media[0] && 'original' in media[0].meta && (media[0])?.meta?.original?.aspect;
|
const aspectRatio = 'meta' in media[0] && 'original' in media[0].meta && (media[0])?.meta.original?.aspect;
|
||||||
|
|
||||||
const getHeight = () => {
|
const getHeight = () => {
|
||||||
if (!aspectRatio) return w * 9 / 16;
|
if (!aspectRatio) return w * 9 / 16;
|
||||||
|
@ -348,7 +348,7 @@ const MediaGallery: React.FC<IMediaGallery> = (props) => {
|
||||||
let itemsDimensions: Dimensions[] = [];
|
let itemsDimensions: Dimensions[] = [];
|
||||||
|
|
||||||
const ratios = Array(size).fill(null).map((_, i) =>
|
const ratios = Array(size).fill(null).map((_, i) =>
|
||||||
'meta' in media[i] && 'original' in media[i].meta && typeof media[i].meta?.original?.aspect === 'number'
|
'meta' in media[i] && 'original' in media[i].meta && typeof media[i].meta.original?.aspect === 'number'
|
||||||
? media[i].meta.original.aspect
|
? media[i].meta.original.aspect
|
||||||
: undefined as unknown as number, // NOTE: the old logic returned undefined anyways, and the implementation of the functions below call 'isNaN', such as the 'isPortrait' function
|
: undefined as unknown as number, // NOTE: the old logic returned undefined anyways, and the implementation of the functions below call 'isNaN', such as the 'isPortrait' function
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue