The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Favicons are being re-rendered on hover (#5849)
gitstart-twenty64b456912aca
diff --git a/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx b/packages/twenty-front/src/modules/object-record/components/RecordChip.tsxindex ad5cc2217b7..ea27165a15d 100644--- a/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx+++ b/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx@@ -2,7 +2,6 @@ import { EntityChip, EntityChipVariant } from 'twenty-ui';import { useMapToObjectRecordIdentifier } from '@/object-metadata/hooks/useMapToObjectRecordIdentifier';import { ObjectRecord } from '@/object-record/types/ObjectRecord';-import { getImageAbsoluteURIOrBase64 } from '~/utils/image/getImageAbsoluteURIOrBase64';export type RecordChipProps = {objectNameSingular: string;@@ -28,9 +27,7 @@ export const RecordChip = ({entityId={record.id}name={objectRecordIdentifier.name}avatarType={objectRecordIdentifier.avatarType}- avatarUrl={- getImageAbsoluteURIOrBase64(objectRecordIdentifier.avatarUrl) || ''- }+ avatarUrl={objectRecordIdentifier.avatarUrl ?? ''}linkToEntity={objectRecordIdentifier.linkToShowPage}className={className}variant={variant}diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsxindex 30fdcb7a777..12d9b3ec786 100644--- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsx+++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsx@@ -1,7 +1,6 @@import { EntityChip } from 'twenty-ui';import { useChipFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useChipFieldDisplay';-import { getImageAbsoluteURIOrBase64 } from '~/utils/image/getImageAbsoluteURIOrBase64';export const ChipFieldDisplay = () => {const { recordValue, generateRecordChipData } = useChipFieldDisplay();@@ -17,7 +16,7 @@ export const ChipFieldDisplay = () => {entityId={recordValue.id}name={recordChipData.name as any}avatarType={recordChipData.avatarType}- avatarUrl={getImageAbsoluteURIOrBase64(recordChipData.avatarUrl) ?? ''}+ avatarUrl={recordChipData.avatarUrl ?? ''}linkToEntity={recordChipData.linkToShowPage}/>);diff --git a/packages/twenty-ui/src/display/avatar/components/Avatar.tsx b/packages/twenty-ui/src/display/avatar/components/Avatar.tsxindex d7024b347fd..1e480c79994 100644--- a/packages/twenty-ui/src/display/avatar/components/Avatar.tsx+++ b/packages/twenty-ui/src/display/avatar/components/Avatar.tsx@@ -1,7 +1,8 @@-import { useState } from 'react';import { isNonEmptyString, isUndefined } from '@sniptt/guards';import clsx from 'clsx';+import { useRecoilState } from 'recoil';+import { invalidAvatarUrlsState } from '@ui/display/avatar/components/states/isInvalidAvatarUrlState';import { Nullable, stringToHslColor } from '@ui/utilities';import styles from './Avatar.module.css';@@ -55,16 +56,20 @@ export const Avatar = ({color,backgroundColor,}: AvatarProps) => {- const [isInvalidAvatarUrl, setIsInvalidAvatarUrl] = useState(false);+ const [invalidAvatarUrls, setInvalidAvatarUrls] = useRecoilState(+ invalidAvatarUrlsState,+ );const noAvatarUrl = !isNonEmptyString(avatarUrl);const placeholderChar = placeholder?.[0]?.toLocaleUpperCase();- const showPlaceholder = noAvatarUrl || isInvalidAvatarUrl;+ const showPlaceholder = noAvatarUrl || invalidAvatarUrls.includes(avatarUrl);const handleImageError = () => {- setIsInvalidAvatarUrl(true);+ if (isNonEmptyString(avatarUrl)) {+ setInvalidAvatarUrls((prev) => [...prev, avatarUrl]);+ }};const fixedColor = color ?? stringToHslColor(entityId ?? '', 75, 25);diff --git a/packages/twenty-ui/src/display/avatar/components/states/isInvalidAvatarUrlState.ts b/packages/twenty-ui/src/display/avatar/components/states/isInvalidAvatarUrlState.tsnew file mode 100644index 00000000000..13d410a6fa4--- /dev/null+++ b/packages/twenty-ui/src/display/avatar/components/states/isInvalidAvatarUrlState.ts@@ -0,0 +1,6 @@+import { atom } from 'recoil';++export const invalidAvatarUrlsState = atom<string[]>({+ key: 'invalidAvatarUrlsState',+ default: [],+});diff --git a/packages/twenty-ui/src/display/index.ts b/packages/twenty-ui/src/display/index.tsindex 74833f5db94..d00a241a8ca 100644--- a/packages/twenty-ui/src/display/index.ts+++ b/packages/twenty-ui/src/display/index.ts@@ -1,5 +1,6 @@export * from './avatar/components/Avatar';export * from './avatar/components/AvatarGroup';+export * from './avatar/components/states/isInvalidAvatarUrlState';export * from './checkmark/components/AnimatedCheckmark';export * from './checkmark/components/Checkmark';export * from './chip/components/Chip';