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

[TAS-1217] 🚸 Add default value to stakeholders #440

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Changes from 2 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
71 changes: 43 additions & 28 deletions components/IscnRegisterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ import { estimateISCNTxGasAndFee, formatISCNTxPayload } from '~/utils/cosmos/isc
import { ISCN_GAS_MULTIPLIER } from '~/constant';
import {
getLikerIdMinApi,
getUserInfoMinByAddress,
API_POST_NUMBERS_PROTOCOL_ASSETS,
} from '~/constant/api';
import { getAccountBalance } from '~/utils/cosmos'
Expand Down Expand Up @@ -1114,38 +1115,52 @@ export default class IscnRegisterForm extends Vue {
}

async mounted() {
if (this.epubMetadata) {
this.name = this.epubMetadata.title;
this.description = this.extractText(this.epubMetadata.description);
this.author.name = this.epubMetadata.author;
this.author.authorDescription = 'Author'
this.language = this.epubMetadata.language
this.tags = this.epubMetadata.tags
this.thumbnailUrl = this.formatArweave(this.epubMetadata.thumbnailUrl) as string
if (this.author.name) {
this.authors.push(this.author)
this.uploadStatus = 'loading'

if (this.epubMetadata) {
this.name = this.epubMetadata.title;
this.description = this.extractText(this.epubMetadata.description);
this.author.name = this.epubMetadata.author;
this.author.authorDescription = 'Author'
this.language = this.epubMetadata.language
this.tags = this.epubMetadata.tags
this.thumbnailUrl = this.formatArweave(this.epubMetadata.thumbnailUrl) as string
if (this.author.name) {
this.authors.push(this.author)
}
}

if (this.address) {
const iscnOwner = await this.fetchUserInfoByAddress(this.address)
this.authors.push(iscnOwner)
}
// ISCN Fee needs Arweave fee to calculate
await this.calculateISCNFee()
this.uploadStatus = ''
}
if (this.address) {
const iscnOwner = {
name: this.$t('iscn.meta.stakeholders.name.placeholder') as string,
wallet: [{
content: this.address,
id: 1,
type: 'like',
isOpenOptions: false,
}],
url: [],
likerId: '',
authorDescription: 'ISCN owner',

async fetchUserInfoByAddress(address: any) {
try {
const { data } = await this.$axios.get(getUserInfoMinByAddress(address))
return {
name: data?.displayName || address,
wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }],
url: [],
likerId: data?.user || '',
authorDescription: data?.description || 'Publisher',
}
} catch (error) {
// eslint-disable-next-line no-console
console.error(error)
return {
name: address,
wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }],
url: [],
likerId: '',
authorDescription: 'Publisher',
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try {
const { data } = await this.$axios.get(getUserInfoMinByAddress(address))
return {
name: data?.displayName || address,
wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }],
url: [],
likerId: data?.user || '',
authorDescription: data?.description || 'Publisher',
}
} catch (error) {
// eslint-disable-next-line no-console
console.error(error)
return {
name: address,
wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }],
url: [],
likerId: '',
authorDescription: 'Publisher',
}
}
let userData: any = null;
try {
({ data: userData } = await this.$axios.get(getUserInfoMinByAddress(address)))
} catch (error) {
// eslint-disable-next-line no-console
console.error(error)
}
return {
name: userData?.displayName || address,
wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }],
url: [],
likerId: userData?.user || '',
authorDescription: userData?.description || 'Publisher',
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.authors.push(iscnOwner)
}
this.uploadStatus = 'loading'
// ISCN Fee needs Arweave fee to calculate
await this.calculateISCNFee()
this.uploadStatus = ''
}

addContentFingerprint() {
this.customContentFingerprints.push(this.contentFingerprintInput)
Expand Down
Loading