Skip to content

Commit

Permalink
Merge branch 'main' into feature/refresh/ui
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwao authored Aug 15, 2022
2 parents 7bd5f97 + 1d4c8a4 commit aa4180d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
11 changes: 11 additions & 0 deletions components/bsx/Gallery/Item/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
</div>
</template>
<template v-slot:footer>
<GalleryItemCarousel
v-if="showRelatedCarousel"
type="related"
:collectionId="nft.collection.id" />
<GalleryItemCarousel type="visited" />
<OfferList
:current-owner-id="nft.currentOwner"
:nftId="id"
Expand Down Expand Up @@ -283,6 +288,12 @@ export default class GalleryItem extends mixins(
)
}
get showRelatedCarousel(): boolean {
return (
Boolean(this.nft.collection?.id) && this.nftsFromSameCollection.length > 0
)
}
public offersUpdate({ offers }) {
this.isMakeOffersAllowed = !offers.find(({ caller }) => {
return caller === this.accountId
Expand Down
4 changes: 2 additions & 2 deletions components/rmrk/Gallery/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<GalleryItemCarousel
v-if="showRelatedCarousel"
type="related"
:collectionId="nft.collectionId" />
:collectionId="nft.collection.id" />
<GalleryItemCarousel type="visited" />

<div class="columns">
Expand Down Expand Up @@ -415,7 +415,7 @@ export default class GalleryItem extends mixins(PrefixMixin) {
get showRelatedCarousel(): boolean {
return (
Boolean(this.nft.collectionId) && this.nftsFromSameCollection.length > 0
Boolean(this.nft.collection?.id) && this.nftsFromSameCollection.length > 0
)
}
Expand Down
9 changes: 5 additions & 4 deletions components/rmrk/Gallery/GalleryItemCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
</template>

<script lang="ts">
import { Component, Vue, Prop } from 'nuxt-property-decorator'
import { Component, mixins, Prop } from 'nuxt-property-decorator'
import { formatNFT } from '~/utils/carousel'
import { visitedNFT } from '~/utils/localStorage'
import { MIN_CAROUSEL_NFT } from '~/utils/constants'
import PrefixMixin from '@/utils/mixins/prefixMixin'
import collectionEntityById from '@/queries/rmrk/subsquid/collectionEntityById.graphql'
import nftEntitiesByIDs from '@/queries/rmrk/subsquid/nftEntitiesByIDs.graphql'
Expand All @@ -26,7 +27,7 @@ import { CarouselNFT } from '@/components/base/types'
/**
* class name
*/
export default class GalleryItemCarousel extends Vue {
export default class GalleryItemCarousel extends mixins(PrefixMixin) {
@Prop({ type: String, required: true }) type!: 'related' | 'visited'
@Prop({ default: '' }) readonly collectionId!: string
Expand All @@ -40,7 +41,7 @@ export default class GalleryItemCarousel extends Vue {
if (this.type === 'related' && this.collectionId) {
const { data } = await this.$apollo.query({
query: collectionEntityById,
client: 'subsquid',
client: this.client,
variables: {
id: this.collectionId,
nftId: this.$route.params.id,
Expand All @@ -55,7 +56,7 @@ export default class GalleryItemCarousel extends Vue {
const { data } = await this.$apollo.query({
query: nftEntitiesByIDs,
client: 'subsquid',
client: this.client,
variables: {
ids,
},
Expand Down
4 changes: 2 additions & 2 deletions queries/rmrk/subsquid/collectionEntityById.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ query collectionEntityById($id: ID!, $nftId: ID!) {
name
nfts(
limit: 20
orderBy: [price_ASC, updatedAt_DESC]
where: { burned_eq: false, price_gt: "0", id_not_eq: $nftId }
orderBy: [updatedAt_DESC]
where: { burned_eq: false, id_not_eq: $nftId }
) {
...nftSubsquid
...nftDetails
Expand Down
5 changes: 3 additions & 2 deletions utils/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { LastEvent } from '~/utils/types/types'
* Get cloudflare images
* Update timestamp
*/
export const formatNFT = async (data): Promise<CarouselNFT[]> => {
if (!data) {
export const formatNFT = async (nfts): Promise<CarouselNFT[]> => {
if (!nfts) {
return []
}

const data = nfts.filter((nft) => Boolean(nft.meta))
const images = await getCloudflareImageLinks(data.map((nft) => nft.meta.id))
const imageOf = getProperImageLink(images)

Expand Down

0 comments on commit aa4180d

Please sign in to comment.