From cbd82d5e7fda9526160e01eccae61ef83d4f864f Mon Sep 17 00:00:00 2001 From: PhilReact Date: Mon, 6 Nov 2023 14:26:19 +0200 Subject: [PATCH] final changes --- core/language/us.json | 3 +- .../friends-view/profile-modal-update.js | 28 ++++++++--- core/src/components/friends-view/profile.js | 47 ++----------------- .../core/components/ChatGroupsModal.js | 1 - .../plugins/core/qdn/browser/browser.src.js | 42 ++++++++++++++--- 5 files changed, 63 insertions(+), 58 deletions(-) diff --git a/core/language/us.json b/core/language/us.json index 8fe50174..87dd5ed3 100644 --- a/core/language/us.json +++ b/core/language/us.json @@ -1236,6 +1236,7 @@ "profile17": "Unable to fetch profile", "profile18": "Open profile", "profile19": "Cannot fetch profile", - "profile20": "Register name" + "profile20": "Register name", + "profile21": "Insert address from UI" } } \ No newline at end of file diff --git a/core/src/components/friends-view/profile-modal-update.js b/core/src/components/friends-view/profile-modal-update.js index 356e2c02..bd31fb09 100644 --- a/core/src/components/friends-view/profile-modal-update.js +++ b/core/src/components/friends-view/profile-modal-update.js @@ -9,6 +9,7 @@ import { } from 'lit-translate'; import '@material/mwc-button'; import '@material/mwc-icon'; +import '@vaadin/tooltip'; import '@material/mwc-dialog'; import '@material/mwc-checkbox'; import { connect } from 'pwa-helpers'; @@ -244,7 +245,16 @@ class ProfileModalUpdate extends connect(store)(LitElement) { const {bio, tagline, wallets, customData} = this.editContent this.bio = bio ?? ''; this.tagline = tagline ?? ''; - this.wallets = wallets ?? {}; + 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.customData = {...customData} this.requestUpdate(); } @@ -253,7 +263,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) { changedProperties.has('qortalRequestCustomData') && this.qortalRequestCustomData ) { - console.log('this.qortalRequestCustomData', this.qortalRequestCustomData) this.isOpenCustomDataModal = true this.newCustomDataField = {...this.qortalRequestCustomData.payload.customData} this.newCustomDataKey = this.qortalRequestCustomData.property @@ -273,10 +282,8 @@ class ProfileModalUpdate extends connect(store)(LitElement) { } async fetchWalletAddress(coin) { - console.log({ coin }); switch (coin) { case 'arrr': - console.log('arrr'); const arrrWalletName = `${coin}Wallet`; const res2 = await parentEpml.request('apiCall', { @@ -352,7 +359,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) { clearFields() { this.bio = ''; this.tagline = ''; - this.wallets = {}; } fillAddress(coin) { @@ -420,7 +426,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) { } render() { - console.log('modal'); return html` `; @@ -669,7 +683,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) { })}
-
+
item.identifier === 'qortal_profile' @@ -391,7 +382,6 @@ class ProfileQdn extends connect(store)(LitElement) { const dataItem = data[0]; try { const response = await this.getRawData(dataItem); - console.log({ response }); if (response.wallets) { this.profileDataVisiting = response // this.setValues(response, dataItem); @@ -425,7 +415,6 @@ class ProfileQdn extends connect(store)(LitElement) { async getProfile() { try { - console.log('hello start') this.error = '' const arbFee = await this.getArbitraryFee(); this.fee = arbFee; @@ -442,20 +431,16 @@ class ProfileQdn extends connect(store)(LitElement) { if (!nameObject) { this.name = null; this.error = 'no name' - console.log('hello', this.error) throw new Error('no name'); } this.hasName = true const name = nameObject.name; - this.imageUrl = `${this.nodeUrl}/arbitrary/THUMBNAIL/${name}/qortal_avatar?async=true&apiKey=${this.myNode.apiKey}`; this.name = name; const url = `${this.nodeUrl}/arbitrary/resources/search?service=DOCUMENT&identifier=qortal_profile&name=${name}&prefix=true&exactmatchnames=true&excludeblocked=true&limit=20`; const res = await fetch(url); let data = ''; try { - console.log({ res }); data = await res.json(); - console.log({ data }); if (Array.isArray(data)) { data = data.filter( (item) => item.identifier === 'qortal_profile' @@ -466,14 +451,12 @@ class ProfileQdn extends connect(store)(LitElement) { const dataItem = data[0]; try { const response = await this.getRawData(dataItem); - console.log({ response }); if (response.wallets) { this.setValues(response, dataItem); } else { this.error = 'Cannot get saved user settings'; } } catch (error) { - console.log({ error }); this.error = 'Cannot get saved user settings'; } } else { @@ -483,7 +466,6 @@ class ProfileQdn extends connect(store)(LitElement) { this.error = 'Unable to perform query'; } } catch (error) { - console.log({ error }); data = { error: 'No resource found', }; @@ -539,7 +521,6 @@ class ProfileQdn extends connect(store)(LitElement) { async saveToQdn(data) { try { - console.log({ data }); this.isSaving = true; if (this.resourceExists === true && this.error) throw new Error('Unable to save'); @@ -576,13 +557,8 @@ class ProfileQdn extends connect(store)(LitElement) { newObject['customData'][key] = newObject.customData[key]; } } - console.log({ newObject }); const newObjectToBase64 = await objectToBase64(newObject); - // const encryptedData = encryptDataGroup({ - // data64: newObjectToBase64, - // publicKeys: [], - // }); - + const worker = new WebWorker2(); try { const resPublish = await publishData({ @@ -605,9 +581,7 @@ class ProfileQdn extends connect(store)(LitElement) { this.profileData = data; store.dispatch(setProfileData(data)); - // this.setValues(newObject, { - // updated: Date.now(), - // }); + worker.terminate(); } catch (error) { worker.terminate(); @@ -643,14 +617,7 @@ class ProfileQdn extends connect(store)(LitElement) { detail: detail, } ); - try { - console.log( - 'hello100', - iframeWindow.document.querySelector('multi-wallet') - ); - } catch (error) { - console.log({ error }); - } + iframeWindow.dispatchEvent(customEvent); }); } @@ -670,7 +637,6 @@ class ProfileQdn extends connect(store)(LitElement) { this.editContent = { ...(this.profileData || {}), }; - console.log({ detail }); if (detail.payload.customData) { this.qortalRequestCustomData = detail; } @@ -702,7 +668,6 @@ class ProfileQdn extends connect(store)(LitElement) { uniqueId: detail.uniqueId, }); } catch (error) { - console.log({ error }); this.sendBackEvent({ response: 'error', uniqueId: detail.uniqueId, @@ -712,10 +677,7 @@ class ProfileQdn extends connect(store)(LitElement) { _handleOpenVisiting(event){ try { - console.log({event}) const name = event.detail; - console.log({name}) - // if(!name) return this.getVisitingProfile(name) this.dialogOpenedProfile = true } catch (error) { @@ -764,6 +726,8 @@ class ProfileQdn extends connect(store)(LitElement) { } avatarFullImage() { + this.imageUrl = `${this.nodeUrl}/arbitrary/THUMBNAIL/${this.nameVisiting}/qortal_avatar?async=true&apiKey=${this.myNode.apiKey}`; + return html` { + if (!data[field] && data[field] !== 0) { + missingFields.push(field); + } + }); + + if (missingFields.length > 0) { + const missingFieldsString = missingFields.join(', '); + const errorMsg = `Missing fields: ${missingFieldsString}` + let data = {}; + data['error'] = errorMsg; + response = JSON.stringify(data); + break + } + + + try { + const customEvent = new CustomEvent('open-visiting-profile', { + detail: data.name + }); + window.parent.dispatchEvent(customEvent); + response = JSON.stringify(true); + } catch (error) { + const obj = {}; + const errorMsg = error.message || 'Failed to open profile'; + obj['error'] = errorMsg; + response = JSON.stringify(obj); + } + break; + } + case actions.GET_WALLET_BALANCE: { const requiredFields = ['coin'];