Skip to content

Commit

Permalink
added Sentry and removed recoil
Browse files Browse the repository at this point in the history
  • Loading branch information
harshit078 committed Nov 12, 2024
1 parent 317fcdc commit d5e7d9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
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);

if (error instanceof ObjectMetadataItemNotFoundError) {
enqueueSnackBar(
`Error with custom object that cannot be found : ${event.reason}`,
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

0 comments on commit d5e7d9e

Please sign in to comment.