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

✨ remove empty rmrk collections #2718

Merged
merged 12 commits into from
Apr 13, 2022
29 changes: 13 additions & 16 deletions components/rmrk/Collection/List/CollectionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div class="card-content">
<nuxt-link :to="`/rmrk/collection/${collection.id}`">
<CollectionDetail
:nfts="collection.nfts.nodes"
:nfts="collection.nfts"
:name="collection.name" />
</nuxt-link>
<b-skeleton :active="isLoading"> </b-skeleton>
Expand Down Expand Up @@ -110,15 +110,15 @@ export default class CollectionList extends mixins(PrefixMixin) {
private searchQuery: SearchQuery = {
search: '',
type: '',
sortBy: 'BLOCK_NUMBER_DESC',
sortBy: 'blockNumber_DESC',
listed: false,
}

private collectionSortOption: string[] = [
'BLOCK_NUMBER_DESC',
'BLOCK_NUMBER_ASC',
'UPDATED_AT_DESC',
'UPDATED_AT_ASC',
'blockNumber_DESC',
'blockNumber_ASC',
'updatedAt_DESC',
'updatedAt_ASC',
]

get isLoading(): boolean {
Expand All @@ -134,7 +134,7 @@ export default class CollectionList extends mixins(PrefixMixin) {

if (this.searchQuery.search) {
params.push({
name: { likeInsensitive: `%${this.searchQuery.search}%` },
name_contains: this.searchQuery.search,
})
}

Expand All @@ -145,7 +145,7 @@ export default class CollectionList extends mixins(PrefixMixin) {
this.$apollo.addSmartQuery('collection', {
query: collectionListWithSearch,
manual: true,
client: this.urlPrefix,
client: this.urlPrefix === 'rmrk' ? 'subsquid' : this.urlPrefix,
loadingKey: 'isLoading',
result: this.handleResult,
variables: () => {
Expand All @@ -161,17 +161,14 @@ export default class CollectionList extends mixins(PrefixMixin) {
},
update: ({ collectionEntity }) => ({
...collectionEntity,
nfts: collectionEntity.nfts.nodes,
nfts: collectionEntity.nfts,
}),
})
}

protected async handleResult({ data }: any) {
this.total = data.collectionEntities.totalCount
this.collections = data.collectionEntities.nodes.map((e: any) => ({
...e,
}))

this.total = data.stats.totalCount
this.collections = data.collectionEntities
const metadataList: string[] = this.collections.map(mapOnlyMetadata)
const imageLinks = await getCloudflareImageLinks(metadataList)

Expand All @@ -192,7 +189,7 @@ export default class CollectionList extends mixins(PrefixMixin) {
try {
const collections = this.$apollo.query({
query: collectionListWithSearch,
client: this.urlPrefix,
client: this.urlPrefix === 'rmrk' ? 'subsquid' : this.urlPrefix,
variables: {
first: this.first,
offset,
Expand All @@ -201,7 +198,7 @@ export default class CollectionList extends mixins(PrefixMixin) {

const {
data: {
collectionEntities: { nodes: collectionList },
collectionEntities: { collectionList },
},
} = await collections

Expand Down
2 changes: 1 addition & 1 deletion components/rmrk/Gallery/CollectionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export default class CollectionItem extends mixins(

if (this.searchQuery.search) {
params.push({
name: { likeInsensitive: `%${this.searchQuery.search}%` },
name: `%${this.searchQuery.search}%`,
})
}

Expand Down
4 changes: 4 additions & 0 deletions langDir/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@
"BLOCK_NUMBER_ASC": "Old first",
"UPDATED_AT_DESC": "Last interacted",
"UPDATED_AT_ASC": "Least Interacted",
"blockNumber_DESC": "New first",
"blockNumber_ASC": "Old first",
"updatedAt_DESC": "Last interacted",
"updatedAt_ASC": "Least Interacted",
"PRICE_DESC": "Price: High to Low",
"PRICE_ASC": "Price: Low to High",
"listed": "Buy now"
Expand Down
40 changes: 20 additions & 20 deletions queries/collectionListWithSearch.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
query collectionListWithSearch(
$first: Int!
$offset: Int
$search: [CollectionEntityFilter!]
$listed: [NFTEntityFilter!]
$orderBy: CollectionEntitiesOrderBy = BLOCK_NUMBER_DESC
$search: [CollectionEntityWhereInput!]
$orderBy: CollectionEntityOrderByInput = blockNumber_DESC
) {
collectionEntities(
orderBy: [$orderBy, BLOCK_NUMBER_DESC]
first: $first
orderBy: [$orderBy, blockNumber_DESC]
limit: $first
offset: $offset
filter: { id: { notLike: "%KAN%" }, and: $search }
where: { nfts_some: { burned_eq: false }, AND: $search }
) {
totalCount
nodes {
...collection
...collectionDetails
nfts(filter: { burned: { distinctFrom: true }, and: $listed }) {
nodes {
id
metadata
name
price
burned
currentOwner
}
}
...collection
...collectionDetails
nfts {
id
metadata
name
price
burned
currentOwner
}
}
stats: collectionEntitiesConnection(
where: { nfts_some: { burned_eq: false }, AND: $search }
orderBy: blockNumber_DESC
) {
totalCount
}
}