Skip to content

Commit

Permalink
Merge pull request #3441 from roiLeo/fix/bsx/collectionSearchOwn
Browse files Browse the repository at this point in the history
🔧 bsx collection sort & own
  • Loading branch information
petersopko committed Jul 15, 2022
2 parents b336bff + e4ab848 commit 5fed485
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
48 changes: 32 additions & 16 deletions components/rmrk/Gallery/CollectionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@
v-bind.sync="searchQuery"
:showOwnerSwitch="!!accountId"
:disableToggle="!totalListed"
:sortOption="collectionProfileSortOption">
:sortOption="
urlPrefix === 'rmrk'
? collectionProfileSortOption
: squidCollectionProfileSortOption
">
<Layout class="mr-5" />
<b-field>
<Pagination
Expand Down Expand Up @@ -132,7 +136,6 @@ import { exist } from '@/components/rmrk/Gallery/Search/exist'
import { NFT } from '@/components/rmrk/service/scheme'
import allCollectionSaleEvents from '@/queries/rmrk/subsquid/allCollectionSaleEvents.graphql'
import collectionChartById from '@/queries/rmrk/subsquid/collectionChartById.graphql'
import collectionById from '@/queries/collectionById.graphql'
import { getCloudflareImageLinks } from '@/utils/cachingStrategy'
import { CollectionChartData as ChartData } from '@/utils/chart'
import { emptyObject } from '@/utils/empty'
Expand All @@ -147,7 +150,7 @@ import { notificationTypes, showNotification } from '@/utils/notification'
import resolveQueryPath from '@/utils/queryPathResolver'
import shouldUpdate from '@/utils/shouldUpdate'
import { sortedEventByDate } from '@/utils/sorting'
import { correctPrefix, ifRMRK, unwrapSafe } from '@/utils/uniquery'
import { correctPrefix, unwrapSafe } from '@/utils/uniquery'
import { Component, mixins, Ref, Watch } from 'nuxt-property-decorator'
import { Debounce } from 'vue-debounce-decorator'
import { CollectionWithMeta, Interaction } from '../service/scheme'
Expand Down Expand Up @@ -204,27 +207,30 @@ export default class CollectionItem extends mixins(
private searchQuery: SearchQuery = {
search: this.$route.query?.search?.toString() ?? '',
type: this.$route.query?.type?.toString() ?? '',
sortBy: this.$route.query?.sort?.toString() ?? 'BLOCK_NUMBER_DESC',
sortBy:
this.$route.query?.sort?.toString() ?? this.urlPrefix === 'rmrk'
? 'BLOCK_NUMBER_DESC'
: 'blockNumber_DESC',
listed: this.$route.query?.listed?.toString() === 'true',
owned: false,
}
public activeTab = 'items'
protected isLoading = true
protected first = 16
protected totalListed = 0
protected stats: NFT[] = []
protected priceData: [ChartData[], ChartData[]] | [] = []
private queryLoading = 0
public eventsOfNftCollection: Interaction[] | [] = []
public ownerEventsOfNftCollection: Interaction[] | [] = []
public selectedEvent = 'all'
public priceChartData: [Date, number][][] = []
private openHistory = true
private openHolder = true
private isLoading = true
private nfts: NFT[] = []
collectionProfileSortOption: string[] = [
// replacee with constant
protected collectionProfileSortOption: string[] = [
'EMOTES_COUNT_DESC',
'BLOCK_NUMBER_DESC',
'BLOCK_NUMBER_ASC',
Expand All @@ -235,6 +241,17 @@ export default class CollectionItem extends mixins(
'SN_ASC',
]
// move to constant
protected squidCollectionProfileSortOption: string[] = [
'blockNumber_DESC',
'blockNumber_ASC',
'updatedAt_DESC',
'updatedAt_ASC',
'price_DESC',
'price_ASC',
'sn_ASC',
]
get hasChartData(): boolean {
return this.priceData.length > 0
}
Expand Down Expand Up @@ -315,9 +332,13 @@ export default class CollectionItem extends mixins(
}
if (this.searchQuery.owned && this.accountId) {
params.push({
currentOwner: { equalTo: this.accountId },
})
if (this.urlPrefix === 'rmrk') {
params.push({
currentOwner: { equalTo: this.accountId },
})
} else {
params.push({ currentOwner_eq: this.accountId })
}
}
return params
Expand All @@ -341,12 +362,7 @@ export default class CollectionItem extends mixins(
client: this.urlPrefix,
variables: {
id: this.id,
// orderBy: 'blockNumber_DESC',
orderBy: ifRMRK(
this.urlPrefix,
this.searchQuery.sortBy,
'blockNumber_DESC'
),
orderBy: this.searchQuery.sortBy,
search: this.buildSearchParam(),
first: this.first,
offset: (page - 1) * this.first,
Expand Down
3 changes: 3 additions & 0 deletions langDir/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@
"PRICE_DESC": "Price: High to Low",
"PRICE_ASC": "Price: Low to High",
"SN_ASC": "Serial Number Ascending",
"price_DESC": "Price: High to Low",
"price_ASC": "Price: Low to High",
"sn_ASC": "Serial Number Ascending",
"listed": "Buy now",
"own": "Own"
},
Expand Down

0 comments on commit 5fed485

Please sign in to comment.