From 0bfd09f9e7bc6a04940ebb453e30383c2c2d82bf Mon Sep 17 00:00:00 2001 From: MarcoMandar Date: Sun, 18 Aug 2024 12:45:27 +0300 Subject: [PATCH 1/4] add registrationCredits and familyRequired cache, fetch all RegistrationCredits and family verification data when relays are updated Signed-off-by: MarcoMandar --- .../DataTableMyRelays/DataTableMyRelays.vue | 27 ++++++++++++++ .../DataTableMyRelaysMobile.vue | 30 ++++++++++++++++ .../columns/RegistrationActionColumn.vue | 35 ++++++------------- nuxt.config.ts | 4 +-- stores/useUserStore.ts | 28 +++++++++++++-- 5 files changed, 95 insertions(+), 29 deletions(-) diff --git a/components/DataTableMyRelays/DataTableMyRelays.vue b/components/DataTableMyRelays/DataTableMyRelays.vue index 1b0ebec..7c09d78 100755 --- a/components/DataTableMyRelays/DataTableMyRelays.vue +++ b/components/DataTableMyRelays/DataTableMyRelays.vue @@ -88,6 +88,29 @@ const ethAddressError = ref(null); const fingerPrintRegister = ref(''); const fingerPrintRegisterError = ref(null); +const relayCredits = ref>({}); +const familyVerified = ref>({}); +const registrationCreditsRequired = ref(true); +const familyRequired = ref(true); + +const fetchRegistrationCredit = async () => { + if (allRelays.value) { + for (const relay of filterUniqueRelays(allRelays.value)) { + relayCredits.value[relay.fingerprint] = + await userStore.hasRegistrationCredit(relay.fingerprint); + familyVerified.value[relay.fingerprint] = await userStore.familyVerified( + relay.fingerprint + ); + } + } + + registrationCreditsRequired.value = userStore.registrationCreditsRequired; + familyRequired.value = userStore.familyRequired; +}; + +// Fetch the registration credits when the relays are loaded +watch(allRelays, fetchRegistrationCredit); + if ((allRelaysError as any).value?.cause?.message == 'rate limited') { toast.add({ id: 'claimable-relays-error', @@ -553,6 +576,10 @@ const handleUnlockClick = async (fingerprint: string) => { userStore.isHardwareRelay(row.fingerprint) " :is-loading="registratorStore.loading" + :has-registration-credit="relayCredits[row.fingerprint]" + :registration-credits-required="registrationCreditsRequired" + :family-verified="familyVerified[row.fingerprint]" + :family-required="familyRequired" />