Merge pull request #63 from PhillipLangMartinez/feature/add-copy-sponsorshiplist

copy key and less time wait
This commit is contained in:
AlphaX-Projects 2022-08-28 10:13:32 +02:00 committed by GitHub
commit 0261cf6090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 12 deletions

View File

@ -423,6 +423,7 @@ export const pageStyles = css`
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
flex-direction: column; flex-direction: column;
overflow-x: hidden;
} }
.warning{ .warning{

View File

@ -127,13 +127,23 @@ class SponsorshipList extends LitElement {
return nodeInfo return nodeInfo
} }
async saveToClipboard(text) {
try {
await navigator.clipboard.writeText(this.privateRewardShareKey)
parentEpml.request('showSnackBar', text)
} catch (err) {
console.error('Copy to clipboard error:', err)
}
}
changeStatus(value){ changeStatus(value){
this.status = value this.status = value
this.saveToClipboard('Copied to clipboard')
} }
async atMount() { async atMount() {
this.changeLanguage() this.changeLanguage()
@ -279,7 +289,7 @@ class SponsorshipList extends LitElement {
removeReceiver() removeReceiver()
} }
async createRewardShare(publicKeyValue) { async createRewardShare(publicKeyValue, isCopy) {
this.openDialogRewardShare = true this.openDialogRewardShare = true
if(!publicKeyValue){ if(!publicKeyValue){
this.errorMessage = "unable to pull public key from the chain, account has no outgoing transactions" this.errorMessage = "unable to pull public key from the chain, account has no outgoing transactions"
@ -379,7 +389,7 @@ class SponsorshipList extends LitElement {
if(txnResponse?.extraData?.rewardSharePrivateKey && (txnResponse?.data?.message?.includes('multiple') || txnResponse?.data?.message?.includes('SELF_SHARE_EXISTS')) ){ if(txnResponse?.extraData?.rewardSharePrivateKey && (txnResponse?.data?.message?.includes('multiple') || txnResponse?.data?.message?.includes('SELF_SHARE_EXISTS')) ){
this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey
this.confirmRelationship(publicKeyValue) this.confirmRelationship(publicKeyValue, isCopy)
} else if (txnResponse.success === false && txnResponse?.message) { } else if (txnResponse.success === false && txnResponse?.message) {
this.errorMessage = txnResponse?.message this.errorMessage = txnResponse?.message
@ -392,7 +402,7 @@ class SponsorshipList extends LitElement {
this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey this.privateRewardShareKey = txnResponse?.extraData?.rewardSharePrivateKey
this.confirmRelationship(publicKeyValue) this.confirmRelationship(publicKeyValue, isCopy)
} else { } else {
this.errorMessage = txnResponse?.data?.message || txnResponse?.message this.errorMessage = txnResponse?.data?.message || txnResponse?.message
@ -406,7 +416,7 @@ class SponsorshipList extends LitElement {
async confirmRelationship(recipientPublicKey){ async confirmRelationship(recipientPublicKey, isCopy){
this.status = 2 this.status = 2
let interval = null let interval = null
let stop = false let stop = false
@ -431,7 +441,7 @@ class SponsorshipList extends LitElement {
this.status = 3 this.status = 3
this.timer = countDown(180, ()=> this.changeStatus(4)); this.timer = countDown(isCopy ? 5 : 180, ()=> this.changeStatus(4));
} }
} catch (error) { } catch (error) {
@ -521,7 +531,7 @@ class SponsorshipList extends LitElement {
<mwc-button @click=${()=> { <mwc-button @click=${()=> {
this.createRewardShare(sponsorship?.publicKey) this.createRewardShare(sponsorship?.publicKey, true)
} }>copy</mwc-button> } }>copy</mwc-button>
</li> </li>
<li class="grid-item grid-item-button"> <li class="grid-item grid-item-button">
@ -665,19 +675,22 @@ class SponsorshipList extends LitElement {
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;"> <div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;">
<span style="color: #000;">${this.privateRewardShareKey}</span> <span style="color: #000;">${this.privateRewardShareKey}</span>
</div> </div>
<mwc-button @click=${()=> {
this.saveToClipboard('Copied to clipboard')
} }>copy
</mwc-button>
</li> </li>
` : ''} ` : ''}
</ul> </ul>
${this.status === 4 ? '' : html`
<div class="warning column"> <div class="warning column">
<p> <p>
Warning: do not leave this plugin or close the Qortal UI until completion! Warning: do not leave this plugin or close the Qortal UI until completion!
</p> </p>
<p class="message-error">${this.errorMessage}</p> <p class="message-error">${this.errorMessage}</p>
</div> </div>
`}
</div> </div>
<mwc-button <mwc-button