Skip to content

Commit

Permalink
fix: Track Activity item screen event correctly (#10987)
Browse files Browse the repository at this point in the history
fix: Activity screen event
  • Loading branch information
olerichter00 authored Oct 22, 2024
1 parent 19ed04b commit eec4a43
Showing 1 changed file with 55 additions and 47 deletions.
102 changes: 55 additions & 47 deletions src/app/Scenes/Activity/ActivityItemScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { OwnerType } from "@artsy/cohesion"
import { Flex, Screen, Skeleton, SkeletonBox, SkeletonText, Spacer } from "@artsy/palette-mobile"
import { ActivityItemScreenQuery } from "__generated__/ActivityItemScreenQuery.graphql"
import { ActivityErrorScreen } from "app/Scenes/Activity/components/ActivityErrorScreen"
import { AlertNotification } from "app/Scenes/Activity/components/AlertNotification"
import { ArticleFeaturedArtistNotification } from "app/Scenes/Activity/components/ArticleFeaturedArtistNotification"
import { ArtworkPublishedNotification } from "app/Scenes/Activity/components/ArtworkPublishedNotification"
import { PartnerOfferCreatedNotification } from "app/Scenes/Activity/components/PartnerOfferCreatedNotification"
import { PartnerShowOpenedNotification } from "app/Scenes/Activity/components/PartnerShowOpenedNotification"
import { ViewingRoomPublishedNotification } from "app/Scenes/Activity/components/ViewingRoomPublishedNotification"
import { goBack, navigate } from "app/system/navigation/navigate"
import { withSuspense } from "app/utils/hooks/withSuspense"
import { ProvideScreenTrackingWithCohesionSchema } from "app/utils/track"
import { screen } from "app/utils/track/helpers"
import { FC, useEffect } from "react"
import { graphql, useLazyLoadQuery } from "react-relay"
import { screen } from "app/utils/track/helpers"
import { ArticleFeaturedArtistNotification } from "app/Scenes/Activity/components/ArticleFeaturedArtistNotification"
import { ViewingRoomPublishedNotification } from "app/Scenes/Activity/components/ViewingRoomPublishedNotification"
import { PartnerOfferCreatedNotification } from "app/Scenes/Activity/components/PartnerOfferCreatedNotification"
import { ActivityErrorScreen } from "app/Scenes/Activity/components/ActivityErrorScreen"
import { PartnerShowOpenedNotification } from "app/Scenes/Activity/components/PartnerShowOpenedNotification"

export const SUPPORTED_NOTIFICATION_TYPES = [
"ARTWORK_ALERT",
Expand Down Expand Up @@ -48,22 +48,34 @@ export const ActivityItemScreenQueryRenderer: FC<ActivityItemScreenQueryRenderer
}
}, [notification])

switch (notification?.notificationType) {
case "ARTWORK_ALERT":
return <AlertNotification notification={data.me?.notification} />
case "ARTWORK_PUBLISHED":
return <ArtworkPublishedNotification notification={data.me?.notification} />
case "ARTICLE_FEATURED_ARTIST":
return <ArticleFeaturedArtistNotification notification={data.me?.notification} />
case "PARTNER_OFFER_CREATED":
return <PartnerOfferCreatedNotification notification={data.me?.notification} />
case "PARTNER_SHOW_OPENED":
return <PartnerShowOpenedNotification notification={data.me?.notification} />
case "VIEWING_ROOM_PUBLISHED":
return <ViewingRoomPublishedNotification notification={data.me?.notification} />
default:
return null
const getActivityContent = () => {
if (!notification) return null

switch (notification?.notificationType) {
case "ARTWORK_ALERT":
return <AlertNotification notification={data.me?.notification} />
case "ARTWORK_PUBLISHED":
return <ArtworkPublishedNotification notification={data.me?.notification} />
case "ARTICLE_FEATURED_ARTIST":
return <ArticleFeaturedArtistNotification notification={data.me?.notification} />
case "PARTNER_OFFER_CREATED":
return <PartnerOfferCreatedNotification notification={data.me?.notification} />
case "PARTNER_SHOW_OPENED":
return <PartnerShowOpenedNotification notification={data.me?.notification} />
case "VIEWING_ROOM_PUBLISHED":
return <ViewingRoomPublishedNotification notification={data.me?.notification} />
default:
return null
}
}

return (
<ProvideScreenTrackingWithCohesionSchema
info={screen({ context_screen_owner_type: OwnerType.activity })}
>
{getActivityContent()}
</ProvideScreenTrackingWithCohesionSchema>
)
},
LoadingFallback: () => <Placeholder />,
ErrorFallback: (fallbackProps) => {
Expand Down Expand Up @@ -94,31 +106,27 @@ const ActivityItemQuery = graphql`

const Placeholder: React.FC = () => {
return (
<ProvideScreenTrackingWithCohesionSchema
info={screen({ context_screen_owner_type: OwnerType.activity })}
>
<Screen>
<Screen.Header onBack={goBack} />

<Screen.Body fullwidth>
<Skeleton>
<Flex m={2}>
<SkeletonText variant="lg-display" mb={2}>
3 New Works by Jonas Lund
</SkeletonText>

<Spacer y={1} />
<Spacer y={0.5} />

<SkeletonText variant="lg-display" mb={1}>
Description
</SkeletonText>
</Flex>

<SkeletonBox width="100%" height={400} />
</Skeleton>
</Screen.Body>
</Screen>
</ProvideScreenTrackingWithCohesionSchema>
<Screen>
<Screen.Header onBack={goBack} />

<Screen.Body fullwidth>
<Skeleton>
<Flex m={2}>
<SkeletonText variant="lg-display" mb={2}>
3 New Works by Jonas Lund
</SkeletonText>

<Spacer y={1} />
<Spacer y={0.5} />

<SkeletonText variant="lg-display" mb={1}>
Description
</SkeletonText>
</Flex>

<SkeletonBox width="100%" height={400} />
</Skeleton>
</Screen.Body>
</Screen>
)
}

0 comments on commit eec4a43

Please sign in to comment.