4
1
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-02-11 17:55:51 +00:00

Fix bug with fetching wallet addresses in profile

This commit is contained in:
Justin Ferrari 2023-11-08 05:25:12 -05:00
parent f00847740b
commit 4c2d9cf938

View File

@ -36,7 +36,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
newFieldName: { type: String },
qortalRequestCustomData: { type: Object },
newCustomDataKey: { type: String },
isSaving: {type: Boolean}
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}
let formWallets = { ...this.wallets };
if (wallets && Object.keys(wallets).length) {
Object.keys(formWallets).forEach((key) => {
if (wallets[key]) {
formWallets[key] = 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() {
@ -312,7 +311,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
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
const copyObj = { ...this.newCustomDataField };
delete copyObj[key];
this.newCustomDataField = copyObj;
}
addField() {
const copyObj = {...this.newCustomDataField}
copyObj[this.newFieldName] = ''
this.newCustomDataField = copyObj
this.newFieldName = ""
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 = ""
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
this.isOpenCustomDataModal = true;
this.newCustomDataField = data;
this.newCustomDataKey = key;
}
removeCustomData(key) {
const copyObj = {...this.customData}
delete copyObj[key]
this.customData = copyObj
const copyObj = { ...this.customData };
delete copyObj[key];
this.customData = copyObj;
}
render() {
@ -479,7 +478,9 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
>
<input
id=${key}
placeholder=${key + ' ' + get('settings.address')}
placeholder=${key +
' ' +
get('settings.address')}
class="input"
.value=${this.wallets[key]}
@change=${(e) => {
@ -502,7 +503,9 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
position="bottom"
hover-delay=${200}
hide-delay=${1}
text=${translate('profile.profile21')}
text=${translate(
'profile.profile21'
)}
>
</vaadin-tooltip>
</div>
@ -516,12 +519,10 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
<div
style="display:flex;justify-content:center;flex-direction:column;gap:25px"
>
<div
style="display:flex;gap:15px;align-items:center"
>
<p
style="color: var(--black);font-size:16px"
>
${key}
@ -529,7 +530,10 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
<mwc-icon
@click=${() =>
this.updateCustomData(key,this.customData[key])}
this.updateCustomData(
key,
this.customData[key]
)}
style="color:var(--black);cursor:pointer"
>edit</mwc-icon
>
@ -561,7 +565,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
</button>
<div style="display:flex;gap:10px;align-items:center">
<button
?disabled="${this.isLoading}"
class="modal-button"
@ -575,14 +578,20 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
?disabled="${this.isLoading}"
class="modal-button"
@click=${() => {
if(this.isSaving) return
if (this.isSaving) return;
this.saveProfile();
}}
>
${this.isSaving ? html`
<paper-spinner-lite active></paper-spinner-lite>
` : ''}
${this.isSaving ? '' : translate('profile.profile3') }
${this.isSaving
? html`
<paper-spinner-lite
active
></paper-spinner-lite>
`
: ''}
${this.isSaving
? ''
: translate('profile.profile3')}
</button>
</div>
</div>
@ -614,14 +623,12 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
>
<input
id="key-name"
placeholder=${translate(
'profile.profile9'
)}
placeholder=${translate('profile.profile9')}
?disabled=${!!this.qortalRequestCustomData}
class="input"
.value=${this.newCustomDataKey}
@change=${(e) => {
this.newCustomDataKey = e.target.value
this.newCustomDataKey = e.target.value;
}}
/>
</div>
@ -629,7 +636,8 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
<div style="height:15px"></div>
<p>${translate('profile.profile10')}</p>
<div style="display: flex;flex-direction: column;">
${Object.keys(this.newCustomDataField).map((key) => {
${Object.keys(this.newCustomDataField).map(
(key) => {
return html`
<div
style="display:flex;justify-content:center;flex-direction:column"
@ -644,16 +652,23 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
<div
style="display:flex;gap:15px;align-items:center"
>
<input
id=${key}
placeholder=${translate('profile.profile13')}
placeholder=${translate(
'profile.profile13'
)}
class="input"
.value=${this.newCustomDataField[key]}
.value=${this
.newCustomDataField[
key
]}
@change=${(e) => {
this.newCustomDataField = {
...this.newCustomDataField,
[key]: e.target.value,
this.newCustomDataField =
{
...this
.newCustomDataField,
[key]: e.target
.value,
};
}}
/>
@ -667,18 +682,19 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
</div>
</div>
`;
})}
}
)}
</div>
<div style="height:15px"></div>
<div style="width:100%;display:flex;justify-content:center;gap:10px;margin-top:30px">
<div
style="width:100%;display:flex;justify-content:center;gap:10px;margin-top:30px"
>
<input
placeholder=${translate('profile.profile12')}
class="input"
.value=${this.newFieldName}
@change=${(e) => {
this.newFieldName = e.target.value
this.newFieldName = e.target.value;
}}
/>
<button
@ -698,8 +714,8 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
class="modal-button-red"
?disabled="${this.isLoading}"
@click="${() => {
this.isOpenCustomDataModal = false
this.newCustomDataKey = ""
this.isOpenCustomDataModal = false;
this.newCustomDataKey = '';
this.newCustomDataField = {};
}}"
>