Skip to content

Commit 0a44f4b

Browse files
committed
Change tables and block namespaces request
1 parent 540dc90 commit 0a44f4b

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

components/data/BlocksTimeline/BlocksTimelineTable.vue

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Tooltip from "@/components/ui/Tooltip.vue"
1010
import { tia, comma, space, formatBytes, getNamespaceID } from "@/services/utils"
1111
1212
/** API */
13-
import { fetchBlockNamespaces } from "@/services/api/block"
13+
import { fetchBlockBlobs } from "@/services/api/block"
1414
import { fetchTransactionsByBlock } from "@/services/api/tx"
1515
1616
/** Store */
@@ -27,7 +27,7 @@ const preview = reactive({
2727
transactions: [],
2828
pfbs: [],
2929
30-
isLoadingPfbs: true,
30+
isLoadingNamespaces: true,
3131
})
3232
3333
const autoSelect = ref(true)
@@ -38,7 +38,7 @@ const handleSelectBlock = (b, isUser) => {
3838
if (preview.block.height === b.height) return
3939
4040
preview.block = b
41-
preview.pfbs = []
41+
preview.namespaces = []
4242
}
4343
4444
const getTransactionsByBlock = async () => {
@@ -104,7 +104,7 @@ watch(
104104
() => preview.block,
105105
async () => {
106106
if (preview.block.stats.tx_count) {
107-
if (preview.block.stats.blobs_size) preview.isLoadingPfbs = true
107+
if (preview.block.stats.blobs_size) preview.isLoadingNamespaces = true
108108
109109
getTransactionsByBlock()
110110
}
@@ -115,13 +115,19 @@ watch(
115115
() => preview.transactions,
116116
async () => {
117117
if (preview.block.stats.blobs_size === 0) {
118-
preview.isLoadingPfbs = false
118+
preview.isLoadingNamespaces = false
119119
return
120120
}
121121
122-
const data = await fetchBlockNamespaces({ height: preview.block.height })
123-
preview.pfbs = data
124-
preview.isLoadingPfbs = false
122+
const data = await fetchBlockBlobs({ height: preview.block.height })
123+
let namespaces = []
124+
125+
data.forEach(blob => {
126+
namespaces.push(blob.namespace)
127+
});
128+
129+
preview.namespaces = Array.from(new Map(namespaces.map(item => [item.id, item])).values());
130+
preview.isLoadingNamespaces = false
125131
},
126132
)
127133
@@ -283,7 +289,7 @@ watch(
283289
<td>
284290
<Flex align="center">
285291
<Text size="13" weight="600" color="primary">
286-
{{ block.stats.tx_count }}
292+
{{ block.stats.blobs_count }}
287293
</Text>
288294
</Flex>
289295
</td>
@@ -460,12 +466,12 @@ watch(
460466
<Flex align="center" justify="between">
461467
<Text size="12" weight="600" color="tertiary">Namespaces</Text>
462468
<Text size="12" weight="600" color="secondary">
463-
{{ preview.pfbs?.length > 3 ? "3 /" : "" }} {{ preview.pfbs?.length }}
469+
{{ preview.namespaces?.length > 3 ? "3 /" : "" }} {{ preview.namespaces?.length }}
464470
</Text>
465471
</Flex>
466472
467473
<Text
468-
v-if="preview.isLoadingPfbs"
474+
v-if="preview.isLoadingNamespaces"
469475
size="12"
470476
weight="600"
471477
color="tertiary"
@@ -474,27 +480,27 @@ watch(
474480
>
475481
Loading namespaces..
476482
</Text>
477-
<Flex v-else-if="preview.pfbs?.length" direction="column" gap="8">
478-
<NuxtLink v-for="pfb in preview.pfbs.slice(0, 3)" :to="`/namespace/${pfb.namespace.namespace_id}`">
483+
<Flex v-else-if="preview.namespaces?.length" direction="column" gap="8">
484+
<NuxtLink v-for="ns in preview.namespaces.slice(0, 3)" :to="`/namespace/${ns.namespace_id}`">
479485
<Outline wide height="32" padding="8" radius="6">
480486
<Flex align="center" justify="between" wide>
481487
<Flex align="center" gap="8">
482488
<Icon name="folder" size="12" color="secondary" />
483489
484490
<Text size="13" weight="600" color="primary" mono>
485-
{{ getNamespaceID(pfb.namespace.namespace_id).slice(0, 4) }}
491+
{{ getNamespaceID(ns.namespace_id).slice(0, 4) }}
486492
</Text>
487493
488494
<Flex align="center" gap="3">
489495
<div v-for="dot in 3" class="dot" />
490496
</Flex>
491497
492498
<Text size="13" weight="600" color="primary" mono>
493-
{{ getNamespaceID(pfb.namespace.namespace_id).slice(-4) }}
499+
{{ getNamespaceID(ns.namespace_id).slice(-4) }}
494500
</Text>
495501
</Flex>
496502
497-
<Text size="12" weight="600" color="tertiary">{{ formatBytes(pfb.namespace.size) }}</Text>
503+
<Text size="12" weight="600" color="tertiary">{{ formatBytes(ns.size) }}</Text>
498504
</Flex>
499505
</Outline>
500506
</NuxtLink>

components/data/LatestPFBTable.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Tooltip from "@/components/ui/Tooltip.vue"
88
import Spinner from "@/components/ui/Spinner.vue"
99
1010
/** Services */
11-
import { tia, space, comma } from "@/services/utils"
11+
import { comma, space, splitAddress, tia } from "@/services/utils"
1212
1313
/** API */
1414
import { fetchLatestPFBs } from "@/services/api/tx"
@@ -37,7 +37,7 @@ isLoading.value = false
3737
<tr>
3838
<th><Text size="12" weight="600" color="tertiary" noWrap>Hash</Text></th>
3939
<th><Text size="12" weight="600" color="tertiary" noWrap>Block Height</Text></th>
40-
<th><Text size="12" weight="600" color="tertiary" noWrap>Time</Text></th>
40+
<th><Text size="12" weight="600" color="tertiary" noWrap>Signer</Text></th>
4141
<th><Text size="12" weight="600" color="tertiary" noWrap>Fee</Text></th>
4242
</tr>
4343
</thead>
@@ -105,7 +105,7 @@ isLoading.value = false
105105
<NuxtLink :to="`/tx/${pfb.hash}`">
106106
<Flex align="center">
107107
<Text size="12" weight="600" color="primary">
108-
{{ DateTime.fromISO(pfb.time).toRelative({ locale: "en", style: "short" }) }}
108+
{{ splitAddress(pfb.signers[0]) }}
109109
</Text>
110110
</Flex>
111111
</NuxtLink>
@@ -208,7 +208,7 @@ isLoading.value = false
208208
209209
min-height: 40px;
210210
211-
padding-right: 24px;
211+
padding-right: 16px;
212212
}
213213
}
214214
}

components/data/RecentNamespacesTable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const handleSort = (by) => {
6565
<thead>
6666
<tr>
6767
<th><Text size="12" weight="600" color="tertiary">Namespace</Text></th>
68-
<th><Text size="12" weight="600" color="tertiary">Height</Text></th>
68+
<th><Text size="12" weight="600" color="tertiary">Block Height</Text></th>
6969
<th @click="handleSort('time')" :class="$style.sortable">
7070
<Flex align="center" gap="6">
7171
<Text size="12" weight="600" color="tertiary">Time</Text>

0 commit comments

Comments
 (0)