From 603f13b655d67ba093cc53c523bdc493f6c51a23 Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Thu, 8 Aug 2024 13:12:46 +0700 Subject: [PATCH 01/48] refactor: unused drops component --- .../unlockable/UnlockableHeroButtons.vue | 86 --------- .../UnlockableLandingMobileBanner.vue | 43 ----- .../unlockable/UnlockableLandingTag.vue | 44 ----- .../unlockable/UnlockableSchedule.vue | 182 ------------------ .../unlockable/utils/useUnlockableTag.ts | 50 ----- components/drops/useDrops.ts | 17 -- 6 files changed, 422 deletions(-) delete mode 100644 components/collection/unlockable/UnlockableHeroButtons.vue delete mode 100644 components/collection/unlockable/UnlockableLandingMobileBanner.vue delete mode 100644 components/collection/unlockable/UnlockableLandingTag.vue delete mode 100644 components/collection/unlockable/UnlockableSchedule.vue delete mode 100644 components/collection/unlockable/utils/useUnlockableTag.ts diff --git a/components/collection/unlockable/UnlockableHeroButtons.vue b/components/collection/unlockable/UnlockableHeroButtons.vue deleted file mode 100644 index 3883cbdf2d..0000000000 --- a/components/collection/unlockable/UnlockableHeroButtons.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - - - diff --git a/components/collection/unlockable/UnlockableLandingMobileBanner.vue b/components/collection/unlockable/UnlockableLandingMobileBanner.vue deleted file mode 100644 index c2c66347b7..0000000000 --- a/components/collection/unlockable/UnlockableLandingMobileBanner.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - diff --git a/components/collection/unlockable/UnlockableLandingTag.vue b/components/collection/unlockable/UnlockableLandingTag.vue deleted file mode 100644 index 662e14bfb6..0000000000 --- a/components/collection/unlockable/UnlockableLandingTag.vue +++ /dev/null @@ -1,44 +0,0 @@ - - - diff --git a/components/collection/unlockable/UnlockableSchedule.vue b/components/collection/unlockable/UnlockableSchedule.vue deleted file mode 100644 index 0d50f1a47b..0000000000 --- a/components/collection/unlockable/UnlockableSchedule.vue +++ /dev/null @@ -1,182 +0,0 @@ - - - diff --git a/components/collection/unlockable/utils/useUnlockableTag.ts b/components/collection/unlockable/utils/useUnlockableTag.ts deleted file mode 100644 index 66eacef897..0000000000 --- a/components/collection/unlockable/utils/useUnlockableTag.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { getDropDetails } from '@/components/drops/useDrops' - -export const useUnlockableTag = (small: boolean) => { - const { $i18n } = useNuxtApp() - - const drop = ref() - - const isReady = computed(() => Boolean(drop.value)) - const isMintedOut = computed(() => drop.value?.isMintedOut) - const isFree = computed(() => drop.value?.isFree) - - const mintStatusKey = computed(() => { - if (isMintedOut.value) { - return 'mint.unlockable.mintedOut' - } - - return isFree.value - ? 'mint.unlockable.freeMintLive' - : 'mint.unlockable.mintLive' - }) - - const mintStatusText = computed(() => - $i18n.t(small ? `${mintStatusKey.value}Small` : mintStatusKey.value), - ) - - const actionText = computed(() => - $i18n.t( - isMintedOut.value - ? 'mint.unlockable.seeListings' - : 'mint.unlockable.takeMe', - ), - ) - - const to = computed(() => - isMintedOut.value - ? `/${DEFAULT_DROP.chain}/collection/${DEFAULT_DROP.id}?listed=true` - : `/${DEFAULT_DROP.chain}/drops/${DEFAULT_DROP.alias}`, - ) - - onBeforeMount(async () => { - drop.value = await getDropDetails(DEFAULT_DROP.alias) - }) - - return { - to, - actionText, - mintStatusText, - isReady, - } -} diff --git a/components/drops/useDrops.ts b/components/drops/useDrops.ts index 3e4e77cd5c..c1d0ae55a1 100644 --- a/components/drops/useDrops.ts +++ b/components/drops/useDrops.ts @@ -3,7 +3,6 @@ import type { Prefix } from '@kodadot1/static' import { parseCETDate } from './utils' import type { GetDropsQuery } from '@/services/fxart' import { getDropById, getDrops } from '@/services/fxart' -import unlockableCollectionById from '@/queries/subsquid/general/unlockableCollectionById.graphql' import collectionByIdMinimal from '@/queries/subsquid/general/collectionByIdMinimal.graphql' import { chainPropListOf } from '@/utils/config/chain.config' import type { DropItem } from '@/params/types' @@ -152,22 +151,6 @@ const getLocalDropStatus = (drop: Omit): DropStatus => { return DropStatus.SCHEDULED } -export const getDropDetails = async (alias: string) => { - const drop = await getDropById(alias) - - const { data: collectionData } = await useAsyncQuery({ - clientId: drop.chain, - query: unlockableCollectionById, - variables: { - id: drop.collection, - }, - }) - - const { collectionEntity } = collectionData.value - - return getFormattedDropItem(collectionEntity, drop) -} - export function useDrop(alias?: string) { const { params } = useRoute() const dropStore = useDropStore() From be72ec12130b2cd5aec655f8bf2f5f9b68f76429 Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Thu, 8 Aug 2024 20:17:51 +0700 Subject: [PATCH 02/48] feat(drops): add DropItem component and refactor drops display logic --- components/drops/DropItem.vue | 36 ++++++++++++++++++ components/drops/Drops.vue | 69 +++++++++++++++-------------------- components/drops/useDrops.ts | 30 +++------------ 3 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 components/drops/DropItem.vue diff --git a/components/drops/DropItem.vue b/components/drops/DropItem.vue new file mode 100644 index 0000000000..a6af697dc4 --- /dev/null +++ b/components/drops/DropItem.vue @@ -0,0 +1,36 @@ + + + diff --git a/components/drops/Drops.vue b/components/drops/Drops.vue index 46fd1145a8..6de7d5a2f3 100644 --- a/components/drops/Drops.vue +++ b/components/drops/Drops.vue @@ -32,18 +32,18 @@ - +
+ +

@@ -52,13 +52,14 @@ {{ $i18n.t('drops.pastArtDrops') }} - +
+ +
import { NeoButton, NeoIcon } from '@kodadot1/brick' -import filter from 'lodash/filter' -import { DropStatus, useDrops } from './useDrops' import { dropsVisible } from '@/utils/config/permission.config' - -const DEFAULT_SKELETON_COUNT = 4 -const CURRENT_DROP_STATUS = Object.values(DropStatus).filter( - status => status !== DropStatus.MINTING_ENDED, -) +import { getDrops } from '~/services/fxart' +import type { DropItem } from '~/params/types' const { $i18n } = useNuxtApp() const { urlPrefix } = usePrefix() -const { drops, loaded, count } = useDrops({ - active: [true], - chain: !isProduction ? [urlPrefix.value] : [], - limit: 100, -}, { async: true }) const isCreateEventModalActive = ref(false) -const currentDrops = computed(() => - filter(drops.value, drop => CURRENT_DROP_STATUS.includes(drop.status)), -) - -const pastDrops = computed(() => - filter(drops.value, { status: DropStatus.MINTING_ENDED }), -) - -const asyncSkeletonCountOf = (amount: number) => count.value ? Math.max(0, Math.round((count.value) / 2) - amount) : DEFAULT_SKELETON_COUNT - const checkRouteAvailability = () => { if (!dropsVisible(urlPrefix.value)) { navigateTo('/') @@ -109,4 +90,14 @@ watch(urlPrefix, () => checkRouteAvailability()) onBeforeMount(() => { checkRouteAvailability() }) + +const dropItems = ref() +onBeforeMount(async () => { + const items = await getDrops({ + active: [true], + chain: !isProduction ? [urlPrefix.value] : [], + limit: 100, + }) + dropItems.value = items +}) diff --git a/components/drops/useDrops.ts b/components/drops/useDrops.ts index c1d0ae55a1..327799535f 100644 --- a/components/drops/useDrops.ts +++ b/components/drops/useDrops.ts @@ -49,40 +49,20 @@ const DROP_LIST_ORDER = [ const ONE_DAYH_IN_MS = 24 * 60 * 60 * 1000 -export function useDrops(query?: GetDropsQuery, { async = false }: { async?: boolean } = { }) { +export function useDrops(query?: GetDropsQuery) { const drops = ref([]) const dropsList = ref([]) const count = computed(() => dropsList.value.length) const loaded = ref(false) - const getDropsAsync = () => { - dropsList.value.forEach((drop) => { - getFormattedDropItem(drop, drop).then((drop: Drop) => { - drops.value = orderBy( - [...drops.value, drop], - [drop => dropsList.value.map(d => d.alias).indexOf(drop.alias)], - ) - }) - }) - - watch(() => drops.value.length === dropsList.value.length, () => { - loaded.value = true - }, { once: true }) - } - onBeforeMount(async () => { dropsList.value = await getDrops(query) - if (async) { - getDropsAsync() - } - else { - drops.value = await Promise.all( - dropsList.value.map(async drop => getFormattedDropItem(drop, drop)), - ) + drops.value = await Promise.all( + dropsList.value.map(async drop => getFormattedDropItem(drop, drop)), + ) - loaded.value = true - } + loaded.value = true }) const sortDrops = computed(() => From d30152c01556ced72b66fce95dc0770e68c76fbf Mon Sep 17 00:00:00 2001 From: Jarsen <31397967+Jarsen136@users.noreply.github.com> Date: Sun, 25 Aug 2024 12:52:36 +0200 Subject: [PATCH 03/48] feat: Item preview: Show creator & current owner --- components/gallery/useGalleryItem.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/gallery/useGalleryItem.ts b/components/gallery/useGalleryItem.ts index 59bca6ff6c..3f717edbd3 100644 --- a/components/gallery/useGalleryItem.ts +++ b/components/gallery/useGalleryItem.ts @@ -7,6 +7,7 @@ import { getCloudflareMp4 } from '@/services/imageWorker' import type { NFT } from '@/components/rmrk/service/scheme' import type { NFTWithMetadata, NftResources } from '@/composables/useNft' import { getMimeType } from '@/utils/gallery/media' +import { getDrops } from '@/services/fxart' interface NFTData { nftEntity?: NFTWithMetadata @@ -73,6 +74,17 @@ export const useGalleryItem = (nftId?: string): GalleryItem => { return } + if (nftEntity.collection.id) { + await getDrops({ + collection: nftEntity.collection.id, + chain: [urlPrefix.value], + }).then((drops) => { + if (drops && drops[0]?.creator) { + nftEntity.issuer = drops[0].creator + } + }) + } + nft.value = nftEntity const resources = nftEntity.resources?.map((resource, index) => { From 0f10165a9d288d2e9ae04b6aebdae26fdfa36074 Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Mon, 26 Aug 2024 14:16:24 +0700 Subject: [PATCH 04/48] refactor(drops): consolidate route availability check in parent component --- components/drops/Drops.vue | 15 +-------------- pages/[prefix]/drops/index.vue | 12 ++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/components/drops/Drops.vue b/components/drops/Drops.vue index 9ca8fe24e0..183aed6825 100644 --- a/components/drops/Drops.vue +++ b/components/drops/Drops.vue @@ -46,7 +46,7 @@ :default-skeleton-count="4" /> -