Improve performance of demo workspace - Rename getImageAbsoluteURIOrBase64 function (#6282)

### Description

1. This PR is a continuation of a previous PR:
https://github.com/twentyhq/twenty/pull/6201#pullrequestreview-2175601222

2. One test case was removed here:
`packages/twenty-front/src/utils/image/__tests__/getImageAbsoluteURI.test.ts`
because since we are not handling base64 images anymore, the result is
the same of the last test case. Would you rather we update the test
instead?


### Refs

- #3514
- https://github.com/twentyhq/twenty/pull/6201

### Demo


https://www.loom.com/share/4f32b535c77a4d418e319b095d09452c?sid=df34adf8-b013-44ef-b794-d54846f52d2d

Fixes #3514

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
This commit is contained in:
gitstart-app[bot]
2024-07-29 14:07:21 +02:00
committed by GitHub
parent 00fea17920
commit fed12ddfcd
31 changed files with 124 additions and 97 deletions

View File

@ -1,9 +1,10 @@
import React from 'react';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import React, { useMemo } from 'react';
import { IconFileUpload, IconTrash, IconUpload, IconX } from 'twenty-ui';
import { Button } from '@/ui/input/button/components/Button';
import { getImageAbsoluteURI } from '~/utils/image/getImageAbsoluteURI';
import { isDefined } from '~/utils/isDefined';
const StyledContainer = styled.div`
@ -105,16 +106,18 @@ export const ImageInput = ({
hiddenFileInput.current?.click();
};
const pictureURI = useMemo(() => getImageAbsoluteURI(picture), [picture]);
return (
<StyledContainer className={className}>
<StyledPicture
withPicture={!!picture}
withPicture={!!pictureURI}
disabled={disabled}
onClick={onUploadButtonClick}
>
{picture ? (
{pictureURI ? (
<img
src={picture || '/images/default-profile-picture.png'}
src={pictureURI || '/images/default-profile-picture.png'}
alt="profile"
/>
) : (
@ -139,7 +142,7 @@ export const ImageInput = ({
onClick={onAbort}
variant="secondary"
title="Abort"
disabled={!picture || disabled}
disabled={!pictureURI || disabled}
fullWidth
/>
) : (
@ -157,7 +160,7 @@ export const ImageInput = ({
onClick={onRemove}
variant="secondary"
title="Remove"
disabled={!picture || disabled}
disabled={!pictureURI || disabled}
fullWidth
/>
</StyledButtonContainer>