From 1797bfebae553c82e2c8f4777085a9c781d2bc74 Mon Sep 17 00:00:00 2001 From: Jarsen <31397967+Jarsen136@users.noreply.github.com> Date: Tue, 31 Oct 2023 01:22:39 +0800 Subject: [PATCH] fix: Not possible to play with generative art drop page when not connected --- components/collection/drop/Generative.vue | 3 ++- components/collection/drop/GenerativePreview.vue | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/components/collection/drop/Generative.vue b/components/collection/drop/Generative.vue index ef77827229..516f8dc87a 100644 --- a/components/collection/drop/Generative.vue +++ b/components/collection/drop/Generative.vue @@ -222,7 +222,8 @@ const mintButtonDisabled = computed(() => Boolean( currentMintedLoading.value || !mintCountAvailable.value || - !selectedImage.value, + !selectedImage.value || + !accountId.value, ), ) diff --git a/components/collection/drop/GenerativePreview.vue b/components/collection/drop/GenerativePreview.vue index ec94dab0bd..26d00ba0f4 100644 --- a/components/collection/drop/GenerativePreview.vue +++ b/components/collection/drop/GenerativePreview.vue @@ -17,8 +17,7 @@ :loading="isLoading" no-shadow loading-with-label - :disabled="!accountId" - @click="generateNft"> + @click="generateNft()"> {{ $t( isLoading @@ -64,7 +63,10 @@ const getHash = (isDefault?: boolean) => { ? chainProperties.value?.ss58Format : getRandomInt(15000) // https://github.com/paritytech/ss58-registry/blob/30889d6c9d332953a6e3333b30513eef89003f64/ss58-registry.json#L1292C17-L1292C22 - return stringToHex(encodeAddress(accountId.value, ss58Format)) + return accountId.value + ? stringToHex(encodeAddress(accountId.value, ss58Format)) + : // random value + ss58Format } const generativeImageUrl = ref( @@ -73,15 +75,15 @@ const generativeImageUrl = ref( const isLoading = ref(false) -onMounted(() => { - generativeImageUrl.value && emit('select', generativeImageUrl.value) +watch([accountId], () => { + generateNft(true) }) const displayUrl = computed(() => { return generativeImageUrl.value || props.image }) -const generateNft = async () => { +const generateNft = (isDefault: boolean = false) => { isLoading.value = true - const metadata = `${props.content}/?hash=${getHash()}` + const metadata = `${props.content}/?hash=${getHash(isDefault)}` generativeImageUrl.value = metadata emit('select', generativeImageUrl.value)