From 17def5f4d36c2e83750c9a8cb20228bd6c9cdff8 Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Sat, 6 Jul 2024 12:08:00 +0300 Subject: [PATCH] fix issues that arose after requests store refactor there are some issues that arose with the async updates to the request objects, where some properties of the request are not yet populated, and therefore the components that render using those properties need not be shown unless those properties are populated --- src/components/StorageRequest.vue | 17 ++++++++++------- src/components/StorageRequests.vue | 29 +++++++++++++++++------------ src/stores/requests.js | 1 + 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/components/StorageRequest.vue b/src/components/StorageRequest.vue index a3d38b4..d5ee319 100644 --- a/src/components/StorageRequest.vue +++ b/src/components/StorageRequest.vue @@ -47,9 +47,9 @@ const timestamps = computed(() => { let { ask, expiry } = request.value.request let { endsAt, expiresAt } = timestampsFor(ask, expiry, requestedAt) return { - requested: new Date(requestedAt * 1000), - expires: new Date(expiresAt * 1000), - ends: new Date(endsAt * 1000) + requested: requestedAt ? new Date(requestedAt * 1000) : undefined, + expires: requestedAt ? new Date(expiresAt * 1000) : undefined, + ends: requestedAt ? new Date(endsAt * 1000) : undefined } }) const requestDetails = computed(() => request.value.request) @@ -116,15 +116,18 @@ function updateEventModerated() {
Requested
- +
Expires
- +
Ends
- +
@@ -222,7 +225,7 @@ function updateEventModerated() { - + diff --git a/src/components/StorageRequests.vue b/src/components/StorageRequests.vue index 5ec26c1..2e11692 100644 --- a/src/components/StorageRequests.vue +++ b/src/components/StorageRequests.vue @@ -14,9 +14,9 @@ const requestsStore = useRequestsStore() const { requests } = storeToRefs(requestsStore) const router = useRouter() const requestsOrdered = computed(() => { - const sorted = Object.entries(requests.value).sort( - ([reqIdA, reqA], [reqIdB, reqB]) => reqB.requestedAt - reqA.requestedAt - ) + const sorted = Object.entries(requests.value) + .sort(([reqIdA, reqA], [reqIdB, reqB]) => reqB.requestedAt - reqA.requestedAt) + .filter(([requestId, { fetched }]) => fetched.request) return sorted }) @@ -157,17 +157,25 @@ onMounted(() => { {
- +
@@ -218,9 +229,3 @@ onMounted(() => { - - diff --git a/src/stores/requests.js b/src/stores/requests.js index 8b7b053..6773c43 100644 --- a/src/stores/requests.js +++ b/src/stores/requests.js @@ -391,6 +391,7 @@ export const useRequestsStore = defineStore( addFromEvent, exists, getBlock, + getRequest, fetchPastRequests, refetchRequestStates, fetchRequestDetails,