From 6279acc20d03f00f8a2509ca613ae2b70e5a8719 Mon Sep 17 00:00:00 2001 From: RcleydsonR Date: Fri, 30 Dec 2022 02:03:23 -0300 Subject: [PATCH] implement logic to await all validDeposits correctly and improve state rendering from listing component --- src/components/ListingComponent.vue | 55 ++++++++++++++++------------ src/utils/blockchain.ts | 56 ++++++++++++++++++++--------- src/views/DepositsHistoryView.vue | 6 ++-- src/views/ManageBidsView.vue | 42 ++++++++++------------ 4 files changed, 94 insertions(+), 65 deletions(-) diff --git a/src/components/ListingComponent.vue b/src/components/ListingComponent.vue index 72da322..3a5cd72 100644 --- a/src/components/ListingComponent.vue +++ b/src/components/ListingComponent.vue @@ -12,8 +12,8 @@ const props = defineProps<{ const itemsToShow = ref([]); // Methods -const showInitialItems = (items: any[]) => { - return items.length > 3 ? items.slice(0, 3) : items; +const showInitialItems = () => { + itemsToShow.value = props.walletTransactions.slice(0, 3); }; const formatEventsAmount = (amount: any) => { @@ -31,31 +31,27 @@ const openEtherscanUrl = (url: string) => { const loadMore = () => { const itemsShowing = itemsToShow.value.length; - if (props.walletTransactions?.length > itemsShowing + 3) - itemsToShow.value?.push( - ...props.walletTransactions.slice(itemsShowing, itemsShowing + 3) - ); - else itemsToShow.value = props.walletTransactions; + itemsToShow.value?.push( + ...props.walletTransactions.slice(itemsShowing, itemsShowing + 3) + ); }; // watch props changes - -watch(props, (newProps) => { +watch(props, async () => { const itemsToShowQty = itemsToShow.value.length; - if (itemsToShowQty == 0) - itemsToShow.value = showInitialItems(props.walletTransactions); + if (itemsToShowQty == 0) showInitialItems(); else itemsToShow.value = - newProps?.walletTransactions.length > itemsToShowQty - ? newProps.walletTransactions.slice(0, itemsToShowQty) - : newProps.walletTransactions; + props.walletTransactions.length > itemsToShowQty + ? props.walletTransactions.slice(0, itemsToShowQty) + : props.walletTransactions; }); //emits const emit = defineEmits(["cancelDeposit", "withdrawDeposit"]); -// initial itemToShow value -itemsToShow.value = showInitialItems(props.walletTransactions); +// initial itemsToShow value +showInitialItems();