Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Rename confusing name regarding epub thumbnail #442

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/IscnRegisterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ export default class IscnRegisterForm extends Vue {
this.author.authorDescription = 'Author'
this.language = this.epubMetadata.language
this.tags = this.epubMetadata.tags
this.thumbnailUrl = this.formatArweave(this.epubMetadata.thumbnailUrl) as string
this.thumbnailUrl = this.formatArweave(this.epubMetadata.thumbnailArweaveId) as string
if (this.author.name) {
this.authors.push(this.author)
}
Expand Down
34 changes: 17 additions & 17 deletions components/IscnUploadForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@
Hash.of(Buffer.from(fileBytes)),
])

epubMetadata.ipfsHash = ipfsHash
epubMetadata.thumbnailIpfsHash = ipfsHash

const fileRecord: any = {
fileName: coverFile.name,
Expand All @@ -547,7 +547,7 @@
}
this.epubMetadataList.push(epubMetadata)
} catch (err) {
console.error(err)

Check warning on line 550 in components/IscnUploadForm.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Unexpected console statement
}
}

Expand Down Expand Up @@ -590,7 +590,7 @@
const deletedFile = this.fileRecords[index];
this.fileRecords.splice(index, 1);

const indexToDelete = this.epubMetadataList.findIndex(item => item.ipfsHash === deletedFile.ipfsHashList);
const indexToDelete = this.epubMetadataList.findIndex(item => item.thumbnailIpfsHash === deletedFile.ipfsHashList);
if (indexToDelete !== -1) {
this.epubMetadataList.splice(indexToDelete, 1);
}
Expand Down Expand Up @@ -635,9 +635,9 @@
}
if (arweaveId) {
this.sentArweaveTransactionInfo.set(ipfsHash, { transactionHash: '', arweaveId });
const metadata = this.epubMetadataList.find((data: any) => data.ipfsHash === ipfsHash)
const metadata = this.epubMetadataList.find((data: any) => data.thumbnailIpfsHash === ipfsHash)
if (metadata) {
metadata.thumbnailUrl = arweaveId;
metadata.thumbnailArweaveId = arweaveId;
}
}
if (!this.arweaveFeeTargetAddress) {
Expand All @@ -654,10 +654,10 @@
}
}

async sendArweaveFeeTx(records: any): Promise<string> {
async sendArweaveFeeTx(record: any): Promise<string> {
logTrackerEvent(this, 'ISCNCreate', 'SendArFeeTx', '', 1);
if (this.sentArweaveTransactionInfo.has(records.ipfsHash)) {
const transactionInfo = this.sentArweaveTransactionInfo.get(records.ipfsHash);
if (this.sentArweaveTransactionInfo.has(record.ipfsHash)) {
const transactionInfo = this.sentArweaveTransactionInfo.get(record.ipfsHash);
if (transactionInfo && transactionInfo.transactionHash) {
return transactionInfo.transactionHash;
}
Expand All @@ -667,12 +667,12 @@
if (!this.signer) throw new Error('SIGNER_NOT_INITED');
if (!this.arweaveFeeTargetAddress) throw new Error('TARGET_ADDRESS_NOT_SET');
this.uploadStatus = 'signing';
const memo = JSON.stringify({ ipfs: records.ipfsHash, fileSize: records.fileBlob?.size || 0 });
const memo = JSON.stringify({ ipfs: record.ipfsHash, fileSize: record.fileBlob?.size || 0 });
try {
const { transactionHash } = await sendLIKE(this.address, this.arweaveFeeTargetAddress, this.arweaveFee.toFixed(), this.signer, memo);
if (transactionHash) {
const existingData = this.sentArweaveTransactionInfo.get(records.ipfsHash) || {};
this.sentArweaveTransactionInfo.set(records.ipfsHash, { ...existingData, transactionHash });
const existingData = this.sentArweaveTransactionInfo.get(record.ipfsHash) || {};
this.sentArweaveTransactionInfo.set(record.ipfsHash, { ...existingData, transactionHash });
return transactionHash;
}

Expand All @@ -687,11 +687,11 @@
return '';
}

async submitToArweave(records: any): Promise<void> {
const existingData = this.sentArweaveTransactionInfo.get(records.ipfsHash) || {};
async submitToArweave(record: any): Promise<void> {
const existingData = this.sentArweaveTransactionInfo.get(record.ipfsHash) || {};
const { transactionHash, arweaveId: uploadArweaveId } = existingData;
if (uploadArweaveId) return
const tempRecord = {...records}
const tempRecord = {...record}
logTrackerEvent(this, 'ISCNCreate', 'SubmitToArweave', '', 1);
if (!tempRecord.fileBlob) return;
this.isOpenSignDialog = true;
Expand All @@ -715,12 +715,12 @@
txHash: tempRecord.transactionHash,
});
if (arweaveId) {
const uploadedData = this.sentArweaveTransactionInfo.get(records.ipfsHash) || {};
this.sentArweaveTransactionInfo.set(records.ipfsHash, { ...uploadedData, arweaveId });
const uploadedData = this.sentArweaveTransactionInfo.get(record.ipfsHash) || {};
this.sentArweaveTransactionInfo.set(record.ipfsHash, { ...uploadedData, arweaveId });
if (tempRecord.fileName.includes('cover.jpeg')) {
const metadata = this.epubMetadataList.find((file: any) => file.ipfsHash === records.ipfsHash)
const metadata = this.epubMetadataList.find((file: any) => file.thumbnailIpfsHash === record.ipfsHash)
if (metadata) {
metadata.thumbnailUrl = arweaveId
metadata.thumbnailArweaveId = arweaveId
}
}
this.$emit('arweaveUploaded', { arweaveId })
Expand Down
Loading