From f588ffe5d34863d277d7d4d5ba97d647e7be7cee Mon Sep 17 00:00:00 2001 From: PhilReact Date: Wed, 8 Nov 2023 12:46:05 +0200 Subject: [PATCH 1/3] fix sponsorship list includes error --- .../sponsorship-list/sponsorship-list.src.js | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index ebc74070..5bb599d9 100644 --- a/plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -721,23 +721,30 @@ class SponsorshipList extends LitElement { } const getTxnRequestResponse = (txnResponse) => { - if(txnResponse.extraData.rewardSharePrivateKey && (txnResponse.data.message.includes('multiple') || txnResponse.data.message.includes('SELF_SHARE_EXISTS'))) { - this.privateRewardShareKey = txnResponse.extraData.rewardSharePrivateKey - this.confirmRelationship(publicKeyValue, isCopy) - } else if (txnResponse.success === false && txnResponse?.message) { - this.errorMessage = txnResponse?.message - this.isLoadingCreateSponsorship = false - throw(txnResponse?.message) - } else if ( - txnResponse.success === true && - !txnResponse.data.error - ) { - this.privateRewardShareKey = txnResponse.extraData.rewardSharePrivateKey - this.confirmRelationship(publicKeyValue, isCopy) + + const extraData = txnResponse && txnResponse.extraData; + const data = txnResponse && txnResponse.data; + const dataMessage = data && data.message; + const extraDataPrivateKey = extraData && extraData.rewardSharePrivateKey; + const txnSuccess = txnResponse && txnResponse.success; + + if (extraDataPrivateKey && typeof dataMessage === 'string' && + (dataMessage.includes('multiple') || dataMessage.includes('SELF_SHARE_EXISTS'))) { + this.privateRewardShareKey = extraDataPrivateKey; + this.confirmRelationship(publicKeyValue, isCopy); + } else if (txnSuccess === false && txnResponse.message) { + this.errorMessage = txnResponse.message; + this.isLoadingCreateSponsorship = false; + throw new Error(txnResponse.message); + } else if (txnSuccess === true && !(data && data.error)) { + this.privateRewardShareKey = extraDataPrivateKey; + this.confirmRelationship(publicKeyValue, isCopy); } else { - this.errorMessage = txnResponse.data.message || txnResponse.message - this.isLoadingCreateSponsorship = false - throw(txnResponse.data.message || txnResponse.message) + // It's a good practice to provide a default error message + const defaultErrorMessage = 'An unknown error occurred.'; + this.errorMessage = dataMessage || txnResponse.message || defaultErrorMessage; + this.isLoadingCreateSponsorship = false; + throw new Error(dataMessage || txnResponse.message || defaultErrorMessage); } } validateReceiver() From 5b9ec54872463ecd81a209021eb3b8fe8f926c3f Mon Sep 17 00:00:00 2001 From: PhilReact Date: Wed, 8 Nov 2023 12:47:02 +0200 Subject: [PATCH 2/3] remove comment --- plugins/plugins/core/sponsorship-list/sponsorship-list.src.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/plugins/core/sponsorship-list/sponsorship-list.src.js b/plugins/plugins/core/sponsorship-list/sponsorship-list.src.js index 5bb599d9..bf552c27 100644 --- a/plugins/plugins/core/sponsorship-list/sponsorship-list.src.js +++ b/plugins/plugins/core/sponsorship-list/sponsorship-list.src.js @@ -740,7 +740,6 @@ class SponsorshipList extends LitElement { this.privateRewardShareKey = extraDataPrivateKey; this.confirmRelationship(publicKeyValue, isCopy); } else { - // It's a good practice to provide a default error message const defaultErrorMessage = 'An unknown error occurred.'; this.errorMessage = dataMessage || txnResponse.message || defaultErrorMessage; this.isLoadingCreateSponsorship = false; From ed6f96f4398fa65709b2826689e699fd69c9e33f Mon Sep 17 00:00:00 2001 From: PhilReact Date: Wed, 8 Nov 2023 13:19:36 +0200 Subject: [PATCH 3/3] add snackbar --- core/language/us.json | 3 ++- core/src/components/friends-view/profile.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/language/us.json b/core/language/us.json index 9778380d..61823579 100644 --- a/core/language/us.json +++ b/core/language/us.json @@ -1239,6 +1239,7 @@ "profile18": "Open profile", "profile19": "Cannot fetch profile", "profile20": "Register name", - "profile21": "Insert address from UI" + "profile21": "Insert address from UI", + "profile22": "Success" } } \ No newline at end of file diff --git a/core/src/components/friends-view/profile.js b/core/src/components/friends-view/profile.js index 8d574ab1..cbce23f8 100644 --- a/core/src/components/friends-view/profile.js +++ b/core/src/components/friends-view/profile.js @@ -593,7 +593,7 @@ class ProfileQdn extends connect(store)(LitElement) { this.resourceExists = true; this.profileData = data; store.dispatch(setProfileData(data)); - + parentEpml.request('showSnackBar', get('profile.profile22')) worker.terminate(); } catch (error) {