Skip to content

Commit

Permalink
Removed curation checks and extra username resolve requests from Feed…
Browse files Browse the repository at this point in the history
…ItemCard
  • Loading branch information
Nopfed committed Jul 16, 2024
1 parent b063ac5 commit b22efda
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 66 deletions.
138 changes: 78 additions & 60 deletions components/FeedItemCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@
<v-row align="end" class="fill-height pa-1 pl-4">
<v-col>
<a class="text-white font-weight-bold">
{{
<!-- {{
isCuration ? data?.title : data?.publication?.title
}}
}} -->
{{ data?.publication?.title }}
</a>
<br>
<a class="text-white font-italic">
Expand Down Expand Up @@ -105,9 +106,9 @@

<script setup lang="ts">
import { VImg } from 'vuetify/lib/components/index.mjs'
import {
type CollaborativeWhitelistCurationState
} from '@artbycity/sdk/dist/web/curations'
// import {
// type CollaborativeWhitelistCurationState
// } from '@artbycity/sdk/dist/web/curations'

const img = ref<VImg>()

Expand All @@ -121,53 +122,59 @@ const props = defineProps<{ id: string }>()
const abc = useArtByCity()
const { protocol, host, port } = abc.arweave.api.config
const gatewayBase = `${protocol}://${host}:${port}`
const isCuration = ref<boolean>(false)
// const isCuration = ref<boolean>(false)

const { data, pending } = useLazyAsyncData(props.id, async () => {
const checkId = await abc.transactions.get(props.id)

if (checkId) {
if (
checkId.tags.find(o => o.name === 'Entity-Type')?.value === 'curation'
) {
// if (
// checkId.tags.find(o => o.name === 'Entity-Type')?.value === 'curation'
// ) {

isCuration.value = true
// isCuration.value = true

try {
const curation = abc
.curations
.get<CollaborativeWhitelistCurationState>(props.id)
// try {
// const curation = abc
// .curations
// .get<CollaborativeWhitelistCurationState>(props.id)

const { cachedValue: { state } } = await curation.contract.readState()
const curatedPublications = []
// const { cachedValue: { state } } = await curation.contract.readState()
// const curatedPublications = []

let count = 0
for (let i of state.items) {
curatedPublications.push(
await abc.legacy.fetchPublication(i)
)
count += 1
if (count === 3){ break }
}

return {
contract: curation,
title: state.title,
desc: state.metadata.description as string,
state,
curatedPublications,
username: await abc.usernames.resolveUsernameFromAddress(state.owner)
}
} catch (error) {
console.error('Error fetching curation', props.id, error)
}
} else {
const publication = await abc.legacy.fetchPublication(props.id)
const username =
await abc.usernames.resolveUsernameFromAddress(publication.creator)

return { publication, username }
}
// let count = 0
// for (let i of state.items) {
// curatedPublications.push(
// await abc.legacy.fetchPublication(i)
// )
// count += 1
// if (count === 3){ break }
// }

// return {
// contract: curation,
// title: state.title,
// desc: state.metadata.description as string,
// state,
// curatedPublications,
// username: await abc.usernames.resolveUsernameFromAddress(state.owner)
// }
// } catch (error) {
// console.error('Error fetching curation', props.id, error)
// }
// } else {
// const publication = await abc.legacy.fetchPublication(props.id)
// const username =
// await abc.usernames.resolveUsernameFromAddress(publication.creator)

// return { publication, username }
// }
const publication = await abc.legacy.fetchPublication(props.id)
// const username =
// await abc.usernames.resolveUsernameFromAddress(publication.creator)

// return { publication, username }
return { publication }
}

return null
Expand All @@ -180,38 +187,49 @@ const src = computed(() => {
return data.value.publication.image.preview.startsWith('data:image')
? data.value.publication.image.preview
: `${gatewayBase}/${data.value.publication.image.preview}`
} else if (data.value.curatedPublications) {
} /*else if (data.value.curatedPublications) {
return data.value.curatedPublications[0]?.image.preview
.startsWith('data:image')
? data.value.curatedPublications[0]?.image.preview
: `${gatewayBase}/${data.value.curatedPublications[0]?.image.preview}`
}
}*/

})

const isPlayable = computed(() => {
if (!data.value) { return false }

if (!isCuration.value) {
return data.value.publication?.image.animated
|| !!data.value.publication?.audio
|| !!data.value.publication?.model
}
// if (!isCuration.value) {
// return data.value.publication?.image.animated
// || !!data.value.publication?.audio
// || !!data.value.publication?.model
// }
return data.value.publication?.image.animated
|| !!data.value.publication?.audio
|| !!data.value.publication?.model
})

const to = computed(() => {
if (!isCuration.value) {
return `/${data.value?.username || data.value?.publication?.creator}/${
data.value?.publication?.slug || data.value?.publication?.id
}`
} else {
return `/curations/${data.value?.contract?.contractId}`
}
// if (!isCuration.value) {
// return `/${data.value?.username || data.value?.publication?.creator}/${
// data.value?.publication?.slug || data.value?.publication?.id
// }`
// } else {
// return `/curations/${data.value?.contract?.contractId}`
// }
// return `/${data.value?.username || data.value?.publication?.creator}/${
// data.value?.publication?.slug || data.value?.publication?.id
// }`
return `/${data.value?.publication?.creator}/${
data.value?.publication?.slug || data.value?.publication?.id
}`
})
const itemAddress = computed(() => {
return isCuration.value
? data?.value?.state?.owner
: data?.value?.publication?.creator
// return isCuration.value
// ? data?.value?.state?.owner
// : data?.value?.publication?.creator
return data?.value?.publication?.creator
})
</script>
12 changes: 6 additions & 6 deletions pages/[profile]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
<v-row class="mt-4" justify="center">
<Avatar :address="data.address" />
</v-row>
<v-row class="mt-4 mb-1 mx-auto" justify="center">
<!-- <v-row class="mt-4 mb-1 mx-auto" justify="center">
<template v-if="data.isProfileOfCurrentUser">
<ProfileEditButton />
</template>
<template v-else>
<!-- <TipButton :address="data.address" /> -->
<!-- <CollaborateMenu :address="data.address" class="mb-4 mx-4" />
<TipButton :address="data.address" />
<CollaborateMenu :address="data.address" class="mb-4 mx-4" />
<CurateMenu :item="data.address" label="Follow" />
<FollowButton
:address="data.address"
:owner="(auth.address as string)"
/> -->
/>
</template>
</v-row>
</v-row> -->
</v-col>
<v-col cols="12" sm="9">
<BioCard :address="data.address" />
Expand Down Expand Up @@ -50,7 +50,7 @@
<v-row>
<v-col>
<template v-if="tab === 'curations'">
<CurationsFeed :address="data.address" />
<!-- <CurationsFeed :address="data.address" /> -->
</template>
<template v-else-if="tab === 'liked'">
<LikesFeed :address="data.address" />
Expand Down

0 comments on commit b22efda

Please sign in to comment.