Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem authored and Artem committed Jun 2, 2023
2 parents e187c8e + f926ee8 commit 8c44096
Show file tree
Hide file tree
Showing 16 changed files with 797 additions and 532 deletions.
28 changes: 24 additions & 4 deletions packages/atlas/src/api/hooks/notifications.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { QueryHookOptions } from '@apollo/client'

import {
GetNftActivitiesCountQuery,
GetNftActivitiesCountQueryVariables,
GetNftActivitiesQuery,
GetNftActivitiesQueryVariables,
GetNotificationsConnectionQuery,
GetNotificationsConnectionQueryVariables,
useGetNftActivitiesCountQuery,
useGetNftActivitiesQuery,
useGetNotificationsConnectionQuery,
} from '@/api/queries/__generated__/notifications.generated'
Expand All @@ -31,6 +34,27 @@ export const useRawNotifications = (
}
}

export const useActivitiesCount = (
memberId?: string,
opts?: QueryHookOptions<GetNftActivitiesCountQuery, GetNftActivitiesCountQueryVariables>
) => {
const { data, ...rest } = useGetNftActivitiesCountQuery({
...opts,
variables: {
memberId: memberId || '',
},
skip: !memberId,
})

return {
nftsBiddedTotalCount: data?.nftsBidded.totalCount,
nftsBoughtTotalCount: data?.nftsBought.totalCount,
nftsSoldTotalCount: data?.nftsSold.totalCount,
nftsIssuedTotalCount: data?.nftsIssued.totalCount,
...rest,
}
}

export const useRawActivities = (
memberId?: string,
sort: NftActivityOrderByInput = NftActivityOrderByInput.EventTimestampDesc,
Expand All @@ -47,10 +71,6 @@ export const useRawActivities = (
})

return {
nftsBiddedTotalCount: data?.nftsBidded.totalCount,
nftsBoughtTotalCount: data?.nftsBought.totalCount,
nftsSoldTotalCount: data?.nftsSold.totalCount,
nftsIssuedTotalCount: data?.nftsIssued.totalCount,
totalCount: data?.nftActivitiesConnection.totalCount,
pageInfo: data?.nftActivitiesConnection.pageInfo,
activities: data?.nftActivitiesConnection.edges,
Expand Down
587 changes: 367 additions & 220 deletions packages/atlas/src/api/queries/__generated__/notifications.generated.tsx

Large diffs are not rendered by default.

146 changes: 61 additions & 85 deletions packages/atlas/src/api/queries/notifications.graphql
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# CHANGE: Throught this file we're now using one `events` query to receive all related events
# (instead of separate queries for each event type)

# Some redundant fields (result of schema "flattening") were also removed from the events,
# as they can now be accessed though deep filtering.

# Note that in this case `orderBy` and `limit` now applies to all events together, not on per-type basis

query GetNotificationsConnection($memberId: String!, $first: Int!, $after: String) {
notificationsConnection(
first: $first
Expand Down Expand Up @@ -37,12 +29,9 @@ query GetNotificationsConnection($memberId: String!, $first: Int!, $after: Strin
...BasicMembershipFields
}
}
auction {
nft {
video {
id
title
}
nft {
video {
...BasicVideoActivityFields
}
}
}
Expand All @@ -58,8 +47,7 @@ query GetNotificationsConnection($memberId: String!, $first: Int!, $after: Strin
price
nft {
video {
id
title
...BasicVideoActivityFields
}
}
}
Expand All @@ -72,8 +60,7 @@ query GetNotificationsConnection($memberId: String!, $first: Int!, $after: Strin
amount
nft {
video {
id
title
...BasicVideoActivityFields
}
}
}
Expand All @@ -88,12 +75,9 @@ query GetNotificationsConnection($memberId: String!, $first: Int!, $after: Strin
bidder {
...BasicMembershipFields
}
auction {
nft {
video {
id
title
}
nft {
video {
...BasicVideoActivityFields
}
}
}
Expand All @@ -107,12 +91,9 @@ query GetNotificationsConnection($memberId: String!, $first: Int!, $after: Strin
bidder {
...BasicMembershipFields
}
auction {
nft {
video {
id
title
}
nft {
video {
...BasicVideoActivityFields
}
}
}
Expand Down Expand Up @@ -254,17 +235,13 @@ query GetNftHistory($nftId: String!) {
}
}

query GetNftActivities(
$memberId: String!
$first: Int!
$after: String
$orderBy: [NftActivityOrderByInput!] = event_timestamp_DESC
) {
query GetNftActivitiesCount($memberId: String!) {
nftsBought: nftActivitiesConnection(
where: {
event: {
OR: [
{
OR: [
{
member: { id_eq: $memberId }
event: {
data: {
isTypeOf_in: [
"EnglishAuctionSettledEventData"
Expand All @@ -274,20 +251,24 @@ query GetNftActivities(
winningBid: { bidder: { id_eq: $memberId } }
}
}
{ data: { isTypeOf_eq: "NftBoughtEventData", buyer: { id_eq: $memberId } } }
]
}
}
{
member: { id_eq: $memberId }
event: { data: { isTypeOf_eq: "NftBoughtEventData", buyer: { id_eq: $memberId } } }
}
]
}
orderBy: $orderBy
orderBy: event_timestamp_DESC
) {
totalCount
}

nftsSold: nftActivitiesConnection(
where: {
event: {
OR: [
{
OR: [
{
member: { id_eq: $memberId }
event: {
data: {
isTypeOf_in: [
"EnglishAuctionSettledEventData"
Expand All @@ -298,7 +279,10 @@ query GetNftActivities(
previousNftOwner: { member: { id_eq: $memberId } }
}
}
{
}
{
member: { id_eq: $memberId }
event: {
data: {
isTypeOf_in: [
"EnglishAuctionSettledEventData"
Expand All @@ -309,10 +293,10 @@ query GetNftActivities(
previousNftOwner: { channel: { ownerMember: { id_eq: $memberId } } }
}
}
]
}
}
]
}
orderBy: $orderBy
orderBy: event_timestamp_DESC
) {
totalCount
}
Expand All @@ -326,25 +310,26 @@ query GetNftActivities(
]
}
}
orderBy: $orderBy
orderBy: event_timestamp_DESC
) {
totalCount
}

nftsBidded: nftActivitiesConnection(
where: { event: { data: { isTypeOf_eq: "AuctionBidMadeEventData", bid: { bidder: { id_eq: $memberId } } } } }
orderBy: $orderBy
orderBy: event_timestamp_DESC
) {
totalCount
}
}

nftActivitiesConnection(
first: $first
after: $after
orderBy: $orderBy # CHANGE: `event_timestamp` now used instead of `createdAt` (which is no longer available)
where: { member: { id_eq: $memberId } } # CHANGE: Simplified filtering
) {
# CHANGE: The actual `event` is now nested as a property of `NftActivity`
query GetNftActivities(
$memberId: String!
$first: Int!
$after: String
$orderBy: [NftActivityOrderByInput!] = event_timestamp_DESC
) {
nftActivitiesConnection(first: $first, after: $after, orderBy: $orderBy, where: { member: { id_eq: $memberId } }) {
totalCount
pageInfo {
endCursor
Expand All @@ -355,7 +340,7 @@ query GetNftActivities(
node {
event {
id
timestamp # CHANGE: `timestamp` now used instead of `createdAt` (which is no longer available)
timestamp
inBlock
data {
... on AuctionBidMadeEventData {
Expand All @@ -372,11 +357,9 @@ query GetNftActivities(
...BasicMembershipFields
}
}
auction {
nft {
video {
...BasicVideoActivityFields
}
nft {
video {
...BasicVideoActivityFields
}
}
}
Expand All @@ -390,11 +373,9 @@ query GetNftActivities(
...BasicMembershipFields
}
amount
auction {
nft {
video {
...BasicVideoActivityFields
}
nft {
video {
...BasicVideoActivityFields
}
}
}
Expand All @@ -421,11 +402,10 @@ query GetNftActivities(
bidder {
...BasicMembershipFields
}
auction {
nft {
video {
...BasicVideoActivityFields
}

nft {
video {
...BasicVideoActivityFields
}
}
amount
Expand All @@ -437,11 +417,9 @@ query GetNftActivities(
bidder {
...BasicMembershipFields
}
auction {
nft {
video {
...BasicVideoActivityFields
}
nft {
video {
...BasicVideoActivityFields
}
}
}
Expand Down Expand Up @@ -489,11 +467,9 @@ query GetNftActivities(
...BasicMembershipFields
}
bid {
auction {
nft {
video {
...BasicVideoActivityFields
}
nft {
video {
...BasicVideoActivityFields
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/atlas/src/components/_nft/NftTile/NftTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Member, NftTileDetails } from './NftTileDetails'

export type NftTileProps = {
status?: 'idle' | 'buy-now' | 'auction'
isInCarousel?: boolean
thumbnail?: VideoThumbnailProps
title?: string | null
owner?: Member
Expand All @@ -38,6 +39,7 @@ export type NftTileProps = {

export const NftTile: FC<NftTileProps> = ({
status,
isInCarousel,
thumbnail,
loading,
title,
Expand Down Expand Up @@ -99,6 +101,7 @@ export const NftTile: FC<NftTileProps> = ({
}}
/>
<NftTileDetails
isInCarousel={isInCarousel}
videoHref={thumbnail?.videoHref as string}
hovered={hovered}
owner={owner}
Expand Down
Loading

0 comments on commit 8c44096

Please sign in to comment.