Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TODO items #8458

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback, useEffect } from 'react';

import { ObjectMetadataItemNotFoundError } from '@/object-metadata/errors/ObjectMetadataNotFoundError';
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import * as Sentry from '@sentry/react';

export const PromiseRejectionEffect = () => {
const { enqueueSnackBar } = useSnackBar();
Expand All @@ -11,7 +11,8 @@ export const PromiseRejectionEffect = () => {
(event: PromiseRejectionEvent) => {
const error = event.reason;

// TODO: connect Sentry here
Sentry.captureException(error);
Comment on lines 12 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider wrapping Sentry.captureException in try/catch to prevent potential errors in error handling itself


if (error instanceof ObjectMetadataItemNotFoundError) {
enqueueSnackBar(
`Error with custom object that cannot be found : ${event.reason}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Using event.reason here is redundant since we already have the error object. Consider using error.message for consistency with the else branch.

Expand Down
18 changes: 4 additions & 14 deletions packages/twenty-ui/src/display/avatar/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { styled } from '@linaria/react';
import { isNonEmptyString, isUndefined } from '@sniptt/guards';
import { useContext, useMemo } from 'react';
import { useRecoilState } from 'recoil';

import { invalidAvatarUrlsState } from '@ui/display/avatar/components/states/isInvalidAvatarUrlState';
import { useContext, useMemo, useState } from 'react';
import { AVATAR_PROPERTIES_BY_SIZE } from '@ui/display/avatar/constants/AvatarPropertiesBySize';
import { AvatarSize } from '@ui/display/avatar/types/AvatarSize';
import { AvatarType } from '@ui/display/avatar/types/AvatarType';
Expand Down Expand Up @@ -63,7 +60,6 @@ export type AvatarProps = {
onClick?: () => void;
};

// TODO: Remove recoil because we don't want it into twenty-ui and find a solution for invalid avatar urls
export const Avatar = ({
avatarUrl,
size = 'md',
Expand All @@ -77,9 +73,7 @@ export const Avatar = ({
backgroundColor,
}: AvatarProps) => {
const { theme } = useContext(ThemeContext);
const [invalidAvatarUrls, setInvalidAvatarUrls] = useRecoilState(
invalidAvatarUrlsState,
);
const [isInvalidAvatarUrl, setIsInvalidAvatarUrl] = useState(false);

const avatarImageURI = useMemo(
() => getImageAbsoluteURI(avatarUrl),
Expand All @@ -89,14 +83,10 @@ export const Avatar = ({
const noAvatarUrl = !isNonEmptyString(avatarImageURI);

const placeholderChar = placeholder?.[0]?.toLocaleUpperCase();

const showPlaceholder =
noAvatarUrl || invalidAvatarUrls.includes(avatarImageURI);
const showPlaceholder = noAvatarUrl || isInvalidAvatarUrl;

const handleImageError = () => {
if (isNonEmptyString(avatarImageURI)) {
setInvalidAvatarUrls((prev) => [...prev, avatarImageURI]);
}
setIsInvalidAvatarUrl(true);
};

const fixedColor =
Expand Down
Loading