@@ -57,27 +57,30 @@ const bookmarkText = computed(() => {
57
57
58
58
const activeTab = ref (" messages" )
59
59
60
- const showAll = ref (false )
61
- const handleShowAll = () => {
62
- showAll .value = ! showAll .value
63
-
64
- amp .log (" toggleShowAll" )
65
- }
66
-
67
60
const messages = ref ([])
68
61
62
+ const offset = ref (0 )
69
63
const events = ref ([])
70
- const filteredEvents = computed (() => (showAll .value ? events .value : events .value .slice (0 , 10 )))
71
64
72
- const { data: rawEvents } = await fetchTxEvents (props .tx .hash )
73
- events .value = rawEvents .value .sort ((a , b ) => a .position - b .position )
74
- cacheStore .current .events = events .value
65
+ const handleLoadMore = async () => {
66
+ if (events .length === props .tx .events_count ) return
67
+
68
+ offset .value += 10
69
+
70
+ const rawEvents = await fetchTxEvents ({ hash: props .tx .hash , offset: offset .value })
71
+ events .value = [... events .value , ... rawEvents].sort ((a , b ) => a .position - b .position )
72
+ cacheStore .current .events = events .value
73
+ }
75
74
76
75
onMounted (async () => {
77
76
isBookmarked .value = !! bookmarksStore .bookmarks .txs .find ((t ) => t .id === props .tx .hash )
78
77
79
78
const data = await fetchTxMessages (props .tx .hash )
80
79
messages .value = data
80
+
81
+ const rawEvents = await fetchTxEvents ({ hash: props .tx .hash })
82
+ events .value = rawEvents .sort ((a , b ) => a .position - b .position )
83
+ cacheStore .current .events = events .value
81
84
})
82
85
83
86
const handleBookmark = () => {
@@ -324,13 +327,7 @@ const handleViewRawEvent = (event) => {
324
327
</Flex >
325
328
326
329
<Flex v-if =" activeTab === 'events'" direction =" column" :class =" [$style.inner, $style.events]" >
327
- <Flex
328
- v-for =" (event, idx) in filteredEvents"
329
- @click =" handleViewRawEvent(event)"
330
- align =" center"
331
- gap =" 12"
332
- :class =" $style.event"
333
- >
330
+ <Flex v-for =" (event, idx) in events" @click =" handleViewRawEvent(event)" align =" center" gap =" 12" :class =" $style.event" >
334
331
<Flex
335
332
direction =" column"
336
333
align =" center"
@@ -607,14 +604,14 @@ const handleViewRawEvent = (event) => {
607
604
</Text >
608
605
</Flex >
609
606
</Flex >
607
+
608
+ <Button @click =" handleLoadMore" type =" secondary" size =" mini" :disabled =" tx.events_count == events.length" >
609
+ Load More
610
+ </Button >
610
611
</Flex >
611
612
<Flex v-if =" activeTab === 'messages'" :class =" $style.inner" >
612
613
<MessagesTable :messages =" messages" />
613
614
</Flex >
614
-
615
- <Button v-if =" events.length > 10" @click =" handleShowAll" type =" secondary" size =" mini" >
616
- {{ !showAll ? "View More" : "Hide" }}
617
- </Button >
618
615
</Flex >
619
616
</Flex >
620
617
</Flex >
0 commit comments