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

refactor(2918): subsquid for ProfileDetail #2975

Merged
merged 44 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
46ad6b5
refactor: subsquid for ProfileDetail
KngZhi May 5, 2022
6dce5df
feat: change client and import address
KngZhi May 8, 2022
9d2284f
fix: process data
KngZhi May 8, 2022
6c15d0b
feat: remap sortby keywords
KngZhi May 8, 2022
a824559
feat: update imported graphql
KngZhi May 8, 2022
d4d6281
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 8, 2022
7aed164
fix: merge conflict
KngZhi May 8, 2022
c511c22
feat: relocate
KngZhi May 8, 2022
8e83cad
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 8, 2022
ef3c30b
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 11, 2022
8892ffc
fix: remove useless comment
KngZhi May 11, 2022
9b7f7c6
fix: and
KngZhi May 11, 2022
c45fb99
refactor: using fragment
KngZhi May 12, 2022
34fbc0a
fix: searchbar issue
KngZhi May 12, 2022
617a8f2
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 12, 2022
806cbb2
fix: name issue and listed filter
KngZhi May 13, 2022
602efb6
refactor: update field name
KngZhi May 13, 2022
ac68cd0
Merge branch 'issue-2918-rewritten-subsquid' of github.com:KngZhi/nft…
KngZhi May 13, 2022
3391a7e
fix: statemin
KngZhi May 13, 2022
8188c6f
fix: westmint
KngZhi May 13, 2022
b8111bf
fix: emoteCount
KngZhi May 13, 2022
c19c3b9
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 13, 2022
c35c9bf
fix: collectionMeta
KngZhi May 13, 2022
d57b16a
Merge branch 'issue-2918-rewritten-subsquid' of github.com:KngZhi/nft…
KngZhi May 13, 2022
dbf332d
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 13, 2022
9762bf7
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 13, 2022
feecf8a
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 15, 2022
3758b3b
fix: relocate general graphql
KngZhi May 16, 2022
d7c8fa4
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 16, 2022
f4da0f8
fix: rename fragment
KngZhi May 16, 2022
ab27f32
Merge branch 'issue-2918-rewritten-subsquid' of github.com:KngZhi/nft…
KngZhi May 16, 2022
c24f252
fix: profile history amount issue
KngZhi May 16, 2022
d91bd91
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 16, 2022
21745f8
fix: using this.client
KngZhi May 17, 2022
481f8b0
Merge branch 'issue-2918-rewritten-subsquid' of github.com:KngZhi/nft…
KngZhi May 17, 2022
fd3b8c3
Merge branch 'main' into issue-2918-rewritten-subsquid
roiLeo May 17, 2022
0b0ae52
fix: sold tab can not search
KngZhi May 17, 2022
3f3fea3
Merge branch 'issue-2918-rewritten-subsquid' of github.com:KngZhi/nft…
KngZhi May 17, 2022
7fdb444
Merge branch 'main' into issue-2918-rewritten-subsquid
vikiival May 20, 2022
08d35cb
fix: based on request
KngZhi May 21, 2022
7fad4ed
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 21, 2022
468c8a2
fix: request
KngZhi May 21, 2022
749489e
Merge branch 'issue-2918-rewritten-subsquid' of github.com:KngZhi/nft…
KngZhi May 21, 2022
c370bbd
Merge branch 'main' into issue-2918-rewritten-subsquid
KngZhi May 21, 2022
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
43 changes: 30 additions & 13 deletions components/rmrk/Gallery/PaginatedCardList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ export default class PaginatedCardList extends mixins(
this.fetchPageData(page)
}

get remapSortBy(): string {
const remapTable = {
BLOCK_NUMBER_DESC: 'blockNumber_DESC',
BLOCK_NUMBER_ASC: 'blockNumber_ASC',
UPDATED_AT_DESC: 'updatedAt_DESC',
UPDATED_AT_ASC: 'updatedAt_ASC',
PRICE_DESC: 'price_DESC',
PRICE_ASC: 'price_ASC',
}

return remapTable[this.searchQuery.sortBy]
}

created() {
this.fetchPageData(this.startPage)
}
Expand All @@ -123,13 +136,17 @@ export default class PaginatedCardList extends mixins(
this.isFetchingData = true
const result = await this.$apollo.query({
query: this.query,
client: this.urlPrefix,
manual: true,
client: 'subsquid',
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
update: ({ nftEntities }) => nftEntities,
loadingKey: 'isLoading',
result: this.handleResult,
variables: {
account: this.account,
orderBy: this.searchQuery.sortBy,
search: this.buildSearchParam(),
first: this.first,
offset: (page - 1) * this.first,
orderBy: this.remapSortBy,
AND: this.buildSearchParam(),
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
limit: this.first,
offset: this.offset,
},
})
await this.handleResult(result, loadDirection)
Expand All @@ -139,22 +156,22 @@ export default class PaginatedCardList extends mixins(

protected async handleResult({ data }: any, loadDirection = 'down') {
if (data) {
const { nodes, totalCount } = data.nFTEntities
const newNfts = nodes.map((e: any) => ({
...e,
emoteCount: e?.emotes?.totalCount,
}))
await getCloudflareImageLinks(newNfts.map(mapOnlyMetadata)).catch(
const {
nftEntities,
nftEntitiesConnection: { totalCount },
} = data
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
await getCloudflareImageLinks(nftEntities.map(mapOnlyMetadata)).catch(
this.$consola.warn
)

if (loadDirection === 'up') {
this.items = newNfts.concat(this.items)
this.items = nftEntities.concat(this.items)
} else {
this.items = this.items.concat(newNfts)
this.items = this.items.concat(nftEntities)
}

this.total = totalCount
// this.items = nftEntities
this.isLoading = false
this.$emit('change', this.total)
}
Expand Down
14 changes: 7 additions & 7 deletions components/rmrk/Profile/ProfileDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@ import { CollectionWithMeta, Pack } from '@/components/rmrk/service/scheme'
import isShareMode from '@/utils/isShareMode'
import shouldUpdate from '@/utils/shouldUpdate'
import shortAddress from '@/utils/shortAddress'
import nftListByIssuer from '@/queries/nftListByIssuer.graphql'
import nftListCollected from '@/queries/nftListCollected.graphql'
import nftListSold from '@/queries/nftListSold.graphql'
import firstNftByIssuer from '@/queries/firstNftByIssuer.graphql'
import PrefixMixin from '@/utils/mixins/prefixMixin'
import InfiniteScrollMixin from '~/utils/mixins/infiniteScrollMixin'
import collectionListByAccount from '@/queries/rmrk/subsquid/collectionListByAccount.graphql'
import { Debounce } from 'vue-debounce-decorator'

import firstNftByIssuer from '@/queries/rmrk/subsquid/general/firstNftByIssuer.graphql'
import nftListByIssuer from '@/queries/rmrk/subsquid/general/nftListByIssuer.graphql'
import nftListCollected from '@/queries/rmrk/subsquid/general/nftListCollected.graphql'
import nftListSold from '@/queries/rmrk/subsquid/general/nftListSold.graphql'

const components = {
GalleryCardList: () =>
import('@/components/rmrk/Gallery/GalleryCardList.vue'),
Expand Down Expand Up @@ -366,7 +367,7 @@ export default class Profile extends mixins(PrefixMixin, InfiniteScrollMixin) {

this.$apollo.addSmartQuery('firstNft', {
query: firstNftByIssuer,
client: this.urlPrefix,
client: 'subsquid',
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
manual: true,
loadingKey: 'isLoading',
result: this.handleResult,
Expand All @@ -377,7 +378,6 @@ export default class Profile extends mixins(PrefixMixin, InfiniteScrollMixin) {
},
fetchPolicy: 'cache-and-network',
})

// this.packs = await rmrkService
// .getPackListForAccount(this.id)
// .then(defaultSortBy);
Expand All @@ -391,7 +391,7 @@ export default class Profile extends mixins(PrefixMixin, InfiniteScrollMixin) {

protected async handleResult({ data }: any) {
if (!this.firstNFTData.image && data) {
const nfts = data.nFTEntities.nodes
const nfts = data.nftEntities
if (nfts?.length) {
const meta = await fetchNFTMetadata(nfts[0])
this.firstNFTData = {
Expand Down
13 changes: 13 additions & 0 deletions queries/rmrk/subsquid/general/firstNftByIssuer.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query firstNftByIssuer($account: String!) {
nftEntities(
where: {
issuer_eq: $account
name_not_contains: "%Kanaria%"
burned_eq: false
},
orderBy: blockNumber_DESC
limit: 1
) {
metadata
}
}
43 changes: 43 additions & 0 deletions queries/rmrk/subsquid/general/nftListByIssuer.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
query nftListByIssuer(
$account: String!
$limit: Int!
$offset: Int
$search: [NFTEntityWhereInput!]
$orderBy: NFTEntityOrderByInput = blockNumber_DESC
) {
nftEntities(
where: {
issuer_eq: $account
name_not_contains: "%Kanaria%"
burned_eq: false
AND: $search
}
orderBy: [$orderBy, blockNumber_DESC]
limit: $limit
offset: $offset
) {
id
metadata
issuer
currentOwner
blockNumber
collection {
id
}
burned
name
sn
price
}
nftEntitiesConnection(
where: {
issuer_eq: $account
name_not_contains: "%Kanaria%"
burned_eq: false
AND: $search
}
orderBy: blockNumber_DESC
) {
totalCount
}
}
43 changes: 43 additions & 0 deletions queries/rmrk/subsquid/general/nftListCollected.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
query nftListCollected(
$account: String!
$limit: Int!
$offset: Int
$orderBy: NFTEntityOrderByInput = blockNumber_DESC
) {
nftEntities(
where: {
issuer_not_eq: $account
currentOwner_eq: $account
name_not_contains: "%Kanaria%"
burned_eq: false
}
orderBy: [$orderBy, blockNumber_DESC]
limit: $limit
offset: $offset
) {
id
burned
# diff
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
collection {
id
}
createdAt
currentOwner
metadata
issuer
name
price
}
# diff
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
nftEntitiesConnection(
where: {
issuer_not_eq: $account
currentOwner_eq: $account
name_not_contains: "%Kanaria%"
burned_eq: false
}
orderBy: blockNumber_DESC
) {
totalCount
}
}
43 changes: 43 additions & 0 deletions queries/rmrk/subsquid/general/nftListSold.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
query nftListSold(
$account: String!
$limit: Int!
$offset: Int
$orderBy: NFTEntityOrderByInput = blockNumber_DESC
) {
nftEntities(
where: {
issuer_eq: $account
currentOwner_not_eq: $account
name_not_contains: "%Kanaria%"
burned_eq: false
}
orderBy: [$orderBy, blockNumber_DESC]
limit: $limit
offset: $offset
) {
id
burned
# diff
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
collection {
id
}
createdAt
currentOwner
metadata
issuer
name
price
}
# diff
KngZhi marked this conversation as resolved.
Show resolved Hide resolved
nftEntitiesConnection(
where: {
issuer_eq: $account
currentOwner_not_eq: $account
name_not_contains: "%Kanaria%"
burned_eq: false
}
orderBy: blockNumber_DESC
) {
totalCount
}
}