feat(ui): display created_by using valueOrNull

This commit is contained in:
psychedelicious 2024-03-19 21:08:10 +11:00
parent e706afe8a6
commit 7a3e19227f

View File

@ -1,6 +1,8 @@
import { ExternalLink, Flex, Tab, TabList, TabPanel, TabPanels, Tabs, Text } from '@invoke-ai/ui-library';
import { IAINoContentFallback } from 'common/components/IAIImageFallback';
import ScrollableContent from 'common/components/OverlayScrollbars/ScrollableContent';
import { useMetadataItem } from 'features/metadata/hooks/useMetadataItem';
import { handlers } from 'features/metadata/util/handlers';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useDebouncedMetadata } from 'services/api/hooks/useDebouncedMetadata';
@ -21,8 +23,9 @@ const ImageMetadataViewer = ({ image }: ImageMetadataViewerProps) => {
// dispatch(setShouldShowImageDetails(false));
// });
const { t } = useTranslation();
const { metadata } = useDebouncedMetadata(image.image_name);
const createdBy = useMetadataItem(metadata, handlers.createdBy);
return (
<Flex
@ -37,12 +40,10 @@ const ImageMetadataViewer = ({ image }: ImageMetadataViewerProps) => {
overflow="hidden"
>
<ExternalLink href={image.image_url} label={image.image_name} />
{metadata && metadata['created_by'] && typeof metadata['created_by'] === 'string' ? (
{createdBy.valueOrNull && (
<Text>
{t('metadata.createdBy')}: {metadata['created_by']}
{t('metadata.createdBy')}: {createdBy.valueOrNull}
</Text>
) : (
<></>
)}
<Tabs variant="line" isLazy={true} display="flex" flexDir="column" w="full" h="full">