From 4c2d9cf938345f65bf03cdc5208bb212ede9f219 Mon Sep 17 00:00:00 2001 From: Justin Ferrari Date: Wed, 8 Nov 2023 05:25:12 -0500 Subject: [PATCH] Fix bug with fetching wallet addresses in profile --- .../friends-view/profile-modal-update.js | 322 +++++++++--------- 1 file changed, 169 insertions(+), 153 deletions(-) diff --git a/core/src/components/friends-view/profile-modal-update.js b/core/src/components/friends-view/profile-modal-update.js index 714467d6..b8e4aafe 100644 --- a/core/src/components/friends-view/profile-modal-update.js +++ b/core/src/components/friends-view/profile-modal-update.js @@ -32,11 +32,11 @@ class ProfileModalUpdate extends connect(store)(LitElement) { hasFetchedArrr: { type: Boolean }, isOpenCustomDataModal: { type: Boolean }, customData: { type: Object }, - newCustomDataField: {type: Object}, - newFieldName: {type: String}, - qortalRequestCustomData: {type: Object}, - newCustomDataKey: {type: String}, - isSaving: {type: Boolean} + newCustomDataField: { type: Object }, + newFieldName: { type: String }, + qortalRequestCustomData: { type: Object }, + newCustomDataKey: { type: String }, + isSaving: { type: Boolean }, }; } @@ -75,11 +75,10 @@ class ProfileModalUpdate extends connect(store)(LitElement) { this.hasFetchedArrr = false; this.isOpenCustomDataModal = false; this.customData = {}; - this.newCustomDataKey = "" + this.newCustomDataKey = ''; this.newCustomDataField = {}; this.newFieldName = ''; - this.isSaving = false - + this.isSaving = false; } static get styles() { @@ -240,20 +239,20 @@ class ProfileModalUpdate extends connect(store)(LitElement) { changedProperties.has('editContent') && this.editContent ) { - const {bio, tagline, wallets, customData} = this.editContent + const { bio, tagline, wallets, customData } = this.editContent; this.bio = bio ?? ''; this.tagline = tagline ?? ''; - let formWallets = {...this.wallets} - if(wallets && Object.keys(wallets).length){ - Object.keys(formWallets).forEach((key)=> { - if(wallets[key]){ - formWallets[key] = wallets[key] + let formWallets = { ...this.wallets }; + if (wallets && Object.keys(wallets).length) { + Object.keys(formWallets).forEach((key) => { + if (wallets[key]) { + formWallets[key] = wallets[key]; } - }) + }); } - this.wallets = formWallets + this.wallets = formWallets; - this.customData = {...customData} + this.customData = { ...customData }; this.requestUpdate(); } if ( @@ -261,13 +260,13 @@ class ProfileModalUpdate extends connect(store)(LitElement) { changedProperties.has('qortalRequestCustomData') && this.qortalRequestCustomData ) { - this.isOpenCustomDataModal = true - this.newCustomDataField = {...this.qortalRequestCustomData.payload.customData} - this.newCustomDataKey = this.qortalRequestCustomData.property + this.isOpenCustomDataModal = true; + this.newCustomDataField = { + ...this.qortalRequestCustomData.payload.customData, + }; + this.newCustomDataKey = this.qortalRequestCustomData.property; this.requestUpdate(); } - - } async firstUpdated() { @@ -308,11 +307,11 @@ class ProfileModalUpdate extends connect(store)(LitElement) { async getSelectedWalletAddress(wallet) { switch (wallet) { case 'arrr': - if(!this.arrrWalletAddress){ + if (!this.arrrWalletAddress) { try { await this.fetchWalletAddress('arrr'); } catch (error) { - console.log({error}) + console.log({ error }); } } // Use address returned by core API @@ -348,8 +347,8 @@ class ProfileModalUpdate extends connect(store)(LitElement) { this.tagline = ''; } - fillAddress(coin) { - const address = this.getSelectedWalletAddress(coin); + async fillAddress(coin) { + const address = await this.getSelectedWalletAddress(coin); if (address) { this.wallets = { ...this.wallets, @@ -365,51 +364,51 @@ class ProfileModalUpdate extends connect(store)(LitElement) { tagline: this.tagline, bio: this.bio, wallets: this.wallets, - customData: this.customData + customData: this.customData, }; - this.isSaving = true + this.isSaving = true; await this.onSubmit(data); this.setIsOpen(false); this.clearFields(); this.onClose('success'); - } catch (error) {} finally { - this.isSaving = false + } catch (error) { + } finally { + this.isSaving = false; } } - removeField(key){ - const copyObj = {...this.newCustomDataField} - delete copyObj[key] - this.newCustomDataField = copyObj + removeField(key) { + const copyObj = { ...this.newCustomDataField }; + delete copyObj[key]; + this.newCustomDataField = copyObj; } - addField(){ - const copyObj = {...this.newCustomDataField} - copyObj[this.newFieldName] = '' - this.newCustomDataField = copyObj - this.newFieldName = "" + addField() { + const copyObj = { ...this.newCustomDataField }; + copyObj[this.newFieldName] = ''; + this.newCustomDataField = copyObj; + this.newFieldName = ''; } - addCustomData(){ - const copyObj = {...this.customData} - copyObj[this.newCustomDataKey] = this.newCustomDataField - this.customData = copyObj - this.newCustomDataKey = "" + addCustomData() { + const copyObj = { ...this.customData }; + copyObj[this.newCustomDataKey] = this.newCustomDataField; + this.customData = copyObj; + this.newCustomDataKey = ''; this.newCustomDataField = {}; - this.newFieldName = '' + this.newFieldName = ''; this.isOpenCustomDataModal = false; } - updateCustomData(key, data){ - this.isOpenCustomDataModal = true - this.newCustomDataField = data - this.newCustomDataKey = key - + updateCustomData(key, data) { + this.isOpenCustomDataModal = true; + this.newCustomDataField = data; + this.newCustomDataKey = key; } - removeCustomData(key){ - const copyObj = {...this.customData} - delete copyObj[key] - this.customData = copyObj + removeCustomData(key) { + const copyObj = { ...this.customData }; + delete copyObj[key]; + this.customData = copyObj; } render() { @@ -479,7 +478,9 @@ class ProfileModalUpdate extends connect(store)(LitElement) { > { @@ -498,13 +499,15 @@ class ProfileModalUpdate extends connect(store)(LitElement) { >upload_2 - + for=${`${key}-upload`} + position="bottom" + hover-delay=${200} + hide-delay=${1} + text=${translate( + 'profile.profile21' + )} + > + `; @@ -516,20 +519,21 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
-
-

- ${key} +

+ ${key}

- this.updateCustomData(key,this.customData[key])} + this.updateCustomData( + key, + this.customData[key] + )} style="color:var(--black);cursor:pointer" >edit @@ -559,31 +563,36 @@ class ProfileModalUpdate extends connect(store)(LitElement) { > ${translate('general.close')} - +
- - - + +
@@ -614,14 +623,12 @@ class ProfileModalUpdate extends connect(store)(LitElement) { > { - this.newCustomDataKey = e.target.value + this.newCustomDataKey = e.target.value; }} /> @@ -629,66 +636,75 @@ class ProfileModalUpdate extends connect(store)(LitElement) {

${translate('profile.profile10')}

- ${Object.keys(this.newCustomDataField).map((key) => { - return html` -
- + ${Object.keys(this.newCustomDataField).map( + (key) => { + return html`
- - { - this.newCustomDataField = { - ...this.newCustomDataField, - [key]: e.target.value, - }; - }} - /> - - - this.removeField(key)} - style="color:var(--black);cursor:pointer" - >remove + ${key} + +
+ { + this.newCustomDataField = + { + ...this + .newCustomDataField, + [key]: e.target + .value, + }; + }} + /> + + + this.removeField(key)} + style="color:var(--black);cursor:pointer" + >remove +
-
- `; - })} + `; + } + )}
-
- { - this.newFieldName = e.target.value - - }} - /> - + { + this.newFieldName = e.target.value; + }} + /> +
@@ -713,7 +729,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) { this.addCustomData(); }} > - ${translate('profile.profile8')} + ${translate('profile.profile8')}