From 6361260d4cfd02371e2f3b7189b3d935cee1942a Mon Sep 17 00:00:00 2001 From: Rohan-cp Date: Tue, 14 May 2024 23:36:15 -0400 Subject: [PATCH 1/2] empty From 16a3ee6db9fb0c2e00f76bee777aee35d10bd679 Mon Sep 17 00:00:00 2001 From: Rohan-cp Date: Wed, 15 May 2024 16:41:16 -0400 Subject: [PATCH 2/2] base --- .../Events/TokensAddedToCollectionFeedEvent.tsx | 3 +-- .../src/components/Feed/FeedListSectionHeader.tsx | 3 +-- .../components/Gallery/GalleryVirtualizedRow.tsx | 3 +-- .../components/ProfileView/GalleryPreviewCard.tsx | 3 +-- .../components/HoverCard/CommunityHoverCard.tsx | 5 +---- .../src/components/HoverCard/UserHoverCard.tsx | 3 +-- .../notifications/SomeoneAdmiredYourComment.tsx | 3 +-- .../notifications/SomeoneRepliedToYourComment.tsx | 2 +- .../CollectionNavbar/CollectionNavbar.tsx | 3 +-- .../src/scenes/NftDetailPage/NftDetailText.tsx | 15 ++++----------- packages/shared/src/utils/unescape.ts | 9 --------- 11 files changed, 13 insertions(+), 39 deletions(-) diff --git a/apps/mobile/src/components/Feed/Events/TokensAddedToCollectionFeedEvent.tsx b/apps/mobile/src/components/Feed/Events/TokensAddedToCollectionFeedEvent.tsx index faf0c68854..062f212d7b 100644 --- a/apps/mobile/src/components/Feed/Events/TokensAddedToCollectionFeedEvent.tsx +++ b/apps/mobile/src/components/Feed/Events/TokensAddedToCollectionFeedEvent.tsx @@ -11,7 +11,6 @@ import { TokensAddedToCollectionFeedEventQueryFragment$key } from '~/generated/T import { MainTabStackNavigatorProp } from '~/navigation/types'; import { contexts } from '~/shared/analytics/constants'; import { removeNullValues } from '~/shared/relay/removeNullValues'; -import unescape from '~/shared/utils/unescape'; import { Typography } from '../../Typography'; import { EventTokenGrid } from '../EventTokenGrid'; @@ -76,7 +75,7 @@ export function TokensAddedToCollectionFeedEvent({ ); }, [eventData.collection?.tokens, eventData.isPreFeed, eventData.newTokens]); - const collectionName = unescape(eventData.collection?.name ?? ''); + const collectionName = eventData.collection?.name ?? ''; return ( diff --git a/apps/mobile/src/components/Feed/FeedListSectionHeader.tsx b/apps/mobile/src/components/Feed/FeedListSectionHeader.tsx index eb69046c64..7fd930c822 100644 --- a/apps/mobile/src/components/Feed/FeedListSectionHeader.tsx +++ b/apps/mobile/src/components/Feed/FeedListSectionHeader.tsx @@ -9,7 +9,6 @@ import { FeedListSectionHeaderFragment$key } from '~/generated/FeedListSectionHe import { MainTabStackNavigatorProp } from '~/navigation/types'; import { contexts } from '~/shared/analytics/constants'; import { getTimeSince } from '~/shared/utils/time'; -import unescape from '~/shared/utils/unescape'; import { GalleryTouchableOpacity } from '../GalleryTouchableOpacity'; import { Typography } from '../Typography'; @@ -62,7 +61,7 @@ export function FeedListSectionHeader({ feedEventRef }: FeedListSectionHeaderPro return null; } - const galleryName = unescape(feedEvent.eventData.gallery?.name || ''); + const galleryName = feedEvent.eventData.gallery?.name || ''; return ( diff --git a/apps/mobile/src/components/Gallery/GalleryVirtualizedRow.tsx b/apps/mobile/src/components/Gallery/GalleryVirtualizedRow.tsx index 0f2379e604..e272df47f6 100644 --- a/apps/mobile/src/components/Gallery/GalleryVirtualizedRow.tsx +++ b/apps/mobile/src/components/Gallery/GalleryVirtualizedRow.tsx @@ -9,7 +9,6 @@ import { Typography } from '~/components/Typography'; import { GalleryVirtualizedRowQueryFragment$key } from '~/generated/GalleryVirtualizedRowQueryFragment.graphql'; import { MainTabStackNavigatorProp } from '~/navigation/types'; import { contexts } from '~/shared/analytics/constants'; -import unescape from '~/shared/utils/unescape'; import { GalleryTouchableOpacity } from '../GalleryTouchableOpacity'; @@ -68,7 +67,7 @@ export function GalleryVirtualizedRow({ queryRef, item, isOnCollectionScreen }: properties={{ variant: 'collection title' }} > - {unescape(item.name || 'Untitled')} + {item.name || 'Untitled'} diff --git a/apps/mobile/src/components/ProfileView/GalleryPreviewCard.tsx b/apps/mobile/src/components/ProfileView/GalleryPreviewCard.tsx index 3b4eba7971..4e93190b65 100644 --- a/apps/mobile/src/components/ProfileView/GalleryPreviewCard.tsx +++ b/apps/mobile/src/components/ProfileView/GalleryPreviewCard.tsx @@ -17,7 +17,6 @@ import { GalleryPreviewCardQueryFragment$key } from '~/generated/GalleryPreviewC import { MainTabStackNavigatorProp, RootStackNavigatorProp } from '~/navigation/types'; import { contexts } from '~/shared/analytics/constants'; import { ReportingErrorBoundary } from '~/shared/errors/ReportingErrorBoundary'; -import unescape from '~/shared/utils/unescape'; import { BottomSheetRow } from '../BottomSheetRow'; import { GalleryTouchableOpacity } from '../GalleryTouchableOpacity'; @@ -85,7 +84,7 @@ export function GalleryPreviewCard({ galleryRef, isFeatured, queryRef }: Gallery - {gallery.name ? unescape(gallery.name) : 'Untitled'} + {gallery.name ?? 'Untitled'} {descriptionFirstLine && ( - + )} diff --git a/apps/web/src/components/HoverCard/UserHoverCard.tsx b/apps/web/src/components/HoverCard/UserHoverCard.tsx index c889987c7a..022cbdf4f7 100644 --- a/apps/web/src/components/HoverCard/UserHoverCard.tsx +++ b/apps/web/src/components/HoverCard/UserHoverCard.tsx @@ -1,4 +1,3 @@ -import unescape from 'lodash/unescape'; import { Route } from 'nextjs-routes'; import { PropsWithChildren, useCallback, useMemo } from 'react'; import { @@ -190,7 +189,7 @@ function UserHoverCardContent({ {user.bio && ( - + )} diff --git a/apps/web/src/components/Notifications/notifications/SomeoneAdmiredYourComment.tsx b/apps/web/src/components/Notifications/notifications/SomeoneAdmiredYourComment.tsx index 4cc946b814..d48b6c296f 100644 --- a/apps/web/src/components/Notifications/notifications/SomeoneAdmiredYourComment.tsx +++ b/apps/web/src/components/Notifications/notifications/SomeoneAdmiredYourComment.tsx @@ -9,7 +9,6 @@ import { ProfilePicture } from '~/components/ProfilePicture/ProfilePicture'; import { SomeoneAdmiredYourCommentFragment$key } from '~/generated/SomeoneAdmiredYourCommentFragment.graphql'; import { AdmireIcon } from '~/icons/SocializeIcons'; import { ErrorWithSentryMetadata } from '~/shared/errors/ErrorWithSentryMetadata'; -import unescape from '~/shared/utils/unescape'; import { NotificationPostPreviewWithBoundary } from './NotificationPostPreview'; import { StyledAdmireIconWrapper } from './SomeoneAdmiredYourToken'; @@ -95,7 +94,7 @@ export default function SomeoneAdmiredYourComment({ notificationRef, onClose }: comment - {unescape(comment?.comment ?? '')} + {comment?.comment ?? ''} diff --git a/apps/web/src/components/Notifications/notifications/SomeoneRepliedToYourComment.tsx b/apps/web/src/components/Notifications/notifications/SomeoneRepliedToYourComment.tsx index 7d833cb862..58f0f70eb4 100644 --- a/apps/web/src/components/Notifications/notifications/SomeoneRepliedToYourComment.tsx +++ b/apps/web/src/components/Notifications/notifications/SomeoneRepliedToYourComment.tsx @@ -138,7 +138,7 @@ export function SomeoneRepliedToYourComment({ notificationRef, queryRef, onClose {timeAgo} - {unescape(comment.comment)} + {comment.comment} { if (query.collectionById?.__typename === 'Collection') { - return unescape(query.collectionById?.name ?? '') || 'untitled'; + return query.collectionById?.name || 'untitled'; } return 'untitled'; diff --git a/apps/web/src/scenes/NftDetailPage/NftDetailText.tsx b/apps/web/src/scenes/NftDetailPage/NftDetailText.tsx index 2d2c4fbfed..f30f17e341 100644 --- a/apps/web/src/scenes/NftDetailPage/NftDetailText.tsx +++ b/apps/web/src/scenes/NftDetailPage/NftDetailText.tsx @@ -144,7 +144,7 @@ function NftDetailText({ queryRef, tokenRef, authenticatedUserOwnsAsset, toggleL } track('Admire Token Click'); - admireToken(token.id, token.dbid, info, decodedTokenName); + admireToken(token.id, token.dbid, info, name); }, [ query.viewer?.__typename, track, @@ -152,7 +152,7 @@ function NftDetailText({ queryRef, tokenRef, authenticatedUserOwnsAsset, toggleL token.id, token.dbid, info, - decodedTokenName, + name, showAuthModal, ]); @@ -169,16 +169,9 @@ function NftDetailText({ queryRef, tokenRef, authenticatedUserOwnsAsset, toggleL token.dbid, token.viewerAdmire.dbid, query.viewer?.user?.dbid, - decodedTokenName + name ); - }, [ - decodedTokenName, - query.viewer, - removeTokenAdmire, - token.dbid, - token.id, - token.viewerAdmire?.dbid, - ]); + }, [name, query.viewer, removeTokenAdmire, token.dbid, token.id, token.viewerAdmire?.dbid]); const isMobile = useIsMobileWindowWidth(); diff --git a/packages/shared/src/utils/unescape.ts b/packages/shared/src/utils/unescape.ts index 35e9d7958b..e69de29bb2 100644 --- a/packages/shared/src/utils/unescape.ts +++ b/packages/shared/src/utils/unescape.ts @@ -1,9 +0,0 @@ -import unescapeFn from 'lodash.unescape'; - -/** Fixes bug where lodash.unescape does not unescape double quotes in our code base */ -export default function unescape(_s: string) { - const s = _s.trim(); - // Check to see if string includes the double quote character; if string does not have it, this is slightly faster - // https://perf.link/#eyJpZCI6ImdubDgwbmp6cWduIiwidGl0bGUiOiJGaW5kaW5nIG51bWJlcnMgaW4gYW4gYXJyYXkgb2YgMTAwMCIsImJlZm9yZSI6ImNvbnN0IHN0ciA9IFwiVGhpcyAgaXMgYSBzdHJpbmdcIiIsInRlc3RzIjpbeyJuYW1lIjoiVGVzdCBDYXNlIiwiY29kZSI6InN0ci5yZXBsYWNlQWxsKFwiJiMzOTtcIiwgJ1wiJykiLCJydW5zIjpbOTgwMDAsMTEwMDAsMTQxNTAwMCw5MzMwMDAsMjY5NDAwMCw3NzQ1MDAwLDkwMDAsNTMwMDAwLDcxMzcwMDAsMTQ5OTAwMCwxNTE0MDAwLDUyMzAwMCwxNjMzMDAwLDExMzkwMDAsMTM1MzAwMCwxNzAxMDAwLDMxMzQwMDAsNTI3MDAwLDEwMDAwMCwyMTgzMDAwLDkwMDAsMTY0NjAwMCwxMDAwLDI5OTMwMDAsMzU0MDAwLDM1NzQwMDAsMTQ3MTAwMCwxMTAwMCwxNTMwMDAwLDM4OTQwMDAsNTMzMDAwLDE0OTkwMDAsNzEzMDAwMCwyMzk2MDAwLDI0NDAwMCw4NDUwMDAsMTY1MjAwMCwzMDAwMCwxMDAwMDAsMjU5MTAwMCw5MDAwLDU3MzAwMCw4OTYwMDAsMjU4NzAwMCwzNTE2MDAwLDE0ODUwMDA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