Skip to content

Commit

Permalink
✨ Add Arweave DRM link option in edit ISCN
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Dec 20, 2024
1 parent 6a85c02 commit 3606594
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 28 deletions.
3 changes: 1 addition & 2 deletions components/SameAsFieldList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ export default class SameAsFieldList extends Vue {
}
@Watch('urlOptions', { deep: true })
onUrlOptionsChanged(newValue: Array<any>) {
console.log('urlOptions', newValue)
onUrlOptionsChanged() {
this.setUrlList()
}
Expand Down
78 changes: 52 additions & 26 deletions pages/edit/_iscnId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,22 @@
/>
</FormField>
<div v-if="step === 2">
<FormField
v-if="shouldShowDRMOption"
:label="$t('IscnRegisterForm.label.drm')"
class="mb-[12px]"
>
<CheckBox v-model="isUseArweaveLink">
{{ $t('IscnRegisterForm.label.drm.details') }}
</CheckBox>
</FormField>
<FormField
:label="$t('iscn.meta.content.fingerprints')"
class="mb-[12px]"
>
<ContentFingerprintLink
v-for="item in contentFingerprints"
:key="item.key"
:key="item"
:item="item"
:class="['mb-[8px]', 'break-all', 'text-[14px]']"
/>
Expand All @@ -77,7 +86,7 @@
>
<SameAsFieldList
:name="name"
:url-options="contentFingerprintOptions"
:url-options="contentFingerprintLinks"
:file-records="uploadFileRecords"
:current-list="sameAsList"
@on-update="(value) => (sameAsList = value)"
Expand Down Expand Up @@ -135,7 +144,7 @@
>
<ContentFingerprintLink
v-for="item in contentFingerprints"
:key="item.key"
:key="item"
:item="item"
:class="['mb-[8px]', 'break-all', 'text-[14px]']"
/>
Expand All @@ -147,7 +156,7 @@
>
<ContentFingerprintLink
v-for="item in sameAs"
:key="item.key"
:key="item"
:item="item"
:class="['mb-[8px]', 'break-all', 'text-[14px]']"
/>
Expand Down Expand Up @@ -294,11 +303,13 @@ export default class EditIscnPage extends Vue {
publisher: string = ''
datePublished: string = ''
isUseArweaveLink= false
shouldShowUploadSection: boolean = false
shouldShowMoreSettings: boolean = false
uploadFileRecords: any = null
uploadIpfsHashList: string[] = []
uploadArweaveIdList: string[] = []
uploadIpfsList: string[] = []
uploadArweaveLinkList: string[] = []
sameAsList: any = []
step: number = 1
Expand All @@ -310,6 +321,17 @@ export default class EditIscnPage extends Vue {
latestVersion: number | string = ''
get combinedArweaveIdList() {
return this.uploadArweaveIdList || []
}
get combinedArweaveLinks(): string[] {
if (this.isUseArweaveLink) {
return this.uploadArweaveLinkList
}
return this.combinedArweaveIdList.map((link) => this.formatArweave(link) as string)
}
get formattedSameAsList() {
if (this.sameAsList.length) {
return this.sameAsList.map(
Expand All @@ -328,20 +350,24 @@ export default class EditIscnPage extends Vue {
return Boolean(this.step === 1 && this.shouldShowUploadSection)
}
get contentFingerprintOptions() {
const array = []
if (this.uploadArweaveIdList) {
array.push(...this.uploadArweaveIdList.map((id: string) => id))
get contentFingerprintLinks() {
const array: string[] = []
if (this.combinedArweaveLinks.length) {
array.push(...this.combinedArweaveLinks)
}
if (this.uploadIpfsList.length) {
array.push(...this.uploadIpfsList.map((ipfs) => ipfs))
if (!this.isUseArweaveLink && this.uploadIpfsHashList.length) {
array.push(...this.uploadIpfsHashList.map((ipfs) => this.formatIpfs(ipfs) as string))
}
if (this.customContentFingerprints.length) {
array.push(...this.customContentFingerprints)
}
return array
}
get shouldShowDRMOption() {
return this.uploadArweaveIdList.filter(Boolean).length
}
get payload() {
return {
...this.contentMetadata,
Expand Down Expand Up @@ -406,24 +432,24 @@ export default class EditIscnPage extends Vue {
this.contentFingerprintInput = ''
}
onSubmitUpload({ fileRecords }: { fileRecords: any[] }) {
onSubmitUpload({
fileRecords,
arweaveIds,
arweaveLinks,
}: {
fileRecords: any[]
arweaveIds: string[]
arweaveLinks: string[]
}) {
this.contentFingerprints = []
if (fileRecords && fileRecords.length) {
this.uploadFileRecords = [...fileRecords]
this.uploadIpfsList = fileRecords.map(
(file) => this.formatIpfs(file.ipfsHash) as string,
)
this.uploadArweaveIdList = fileRecords.map(
(file) => this.formatArweave(file.arweaveId) as string,
)
this.contentFingerprints = [
...fileRecords.map(
(file) => this.formatFileSHA256(file.fileSHA256) as string,
),
...this.uploadIpfsList,
...this.uploadArweaveIdList,
]
}
if (arweaveIds && arweaveIds.length) {
this.uploadArweaveIdList = [...arweaveIds]
}
if (arweaveLinks && arweaveLinks.length) {
this.uploadArweaveLinkList = [...arweaveLinks]
}
logTrackerEvent(this, 'ISCNEdit', 'ISCNConfirmFile', '', 1)
this.step = 2
Expand Down

0 comments on commit 3606594

Please sign in to comment.