From bf03a1764df0c37c7bf2bdedc3b224e86a7d6f93 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Tue, 7 Nov 2023 15:55:01 +0200 Subject: [PATCH] fixes --- core/language/us.json | 4 +-- core/src/components/friends-view/profile.js | 33 +++++++++++++------ .../plugins/core/qdn/browser/browser.src.js | 7 ++-- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/core/language/us.json b/core/language/us.json index 4756583f..9778380d 100644 --- a/core/language/us.json +++ b/core/language/us.json @@ -1226,14 +1226,14 @@ "profile5": "Bio", "profile6": "Wallet Addresses", "profile7": "Fill from UI", - "profile8": "Add custom data", + "profile8": "Add custom property", "profile9": "Property name", "profile10": "Fields", "profile11": "Add new field", "profile12": "Field name", "profile13": "Fill out", "profile14": "Activity", - "profile15": "No data", + "profile15": "No value", "profile16": "This name has no profile", "profile17": "Unable to fetch profile", "profile18": "Open profile", diff --git a/core/src/components/friends-view/profile.js b/core/src/components/friends-view/profile.js index b843ffc6..8d574ab1 100644 --- a/core/src/components/friends-view/profile.js +++ b/core/src/components/friends-view/profile.js @@ -326,6 +326,7 @@ class ProfileQdn extends connect(store)(LitElement) { return ret; } + async setValues(response, resource) { if (response) { let data = { ...response }; @@ -336,7 +337,6 @@ class ProfileQdn extends connect(store)(LitElement) { const decryptedData = decryptGroupData( data.customData[key] ); - if (decryptedData && !decryptedData.error) { const decryptedDataToBase64 = uint8ArrayToObject(decryptedData); @@ -541,18 +541,31 @@ class ProfileQdn extends connect(store)(LitElement) { const getArbitraryFee = await this.getArbitraryFee(); const feeAmount = getArbitraryFee.fee; - let newObject = { ...data }; + let newObject = structuredClone(data) for (const key of Object.keys(newObject.customData || {})) { if (key.includes('-private')) { - const toBase64 = await objectToBase64( - newObject.customData[key] - ); - const encryptedData = encryptDataGroup({ - data64: toBase64, - publicKeys: [], - }); - newObject['customData'][key] = encryptedData; + const dataKey = newObject.customData[key] + let isBase64 = false + try { + const decodedString = atob(dataKey); + isBase64 = decodedString.includes('qortalGroupEncryptedData') + } catch (e) { + console.log(e) + } + if(isBase64){ + newObject['customData'][key] = newObject.customData[key]; + } else { + const toBase64 = await objectToBase64( + newObject.customData[key] + ); + const encryptedData = encryptDataGroup({ + data64: toBase64, + publicKeys: [], + }); + newObject['customData'][key] = encryptedData; + } + } else { newObject['customData'][key] = newObject.customData[key]; } diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js index 59e46825..8f7d07e2 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -2206,11 +2206,12 @@ class WebBrowser extends LitElement { // Set up an event listener to wait for the response window.addEventListener('qortal-request-set-profile-data-response', handleResponseEvent); }); + if(!res.response) throw new Error('Failed to set property') + response = JSON.stringify(res.response); - response = JSON.stringify(res); } catch (error) { const obj = {}; - const errorMsg = error.message || 'Failed to join the group.'; + const errorMsg = error.message || 'Failed to set property.'; obj['error'] = errorMsg; response = JSON.stringify(obj); } finally { @@ -3792,7 +3793,7 @@ async function showModalAndWait(type, data) { ` : ''} ${type === actions.SET_PROFILE_DATA ? `