@@ -57,27 +57,30 @@ const bookmarkText = computed(() => {
5757
5858const activeTab = ref (" messages" )
5959
60- const showAll = ref (false )
61- const handleShowAll = () => {
62- showAll .value = ! showAll .value
63-
64- amp .log (" toggleShowAll" )
65- }
66-
6760const messages = ref ([])
6861
62+ const offset = ref (0 )
6963const events = ref ([])
70- const filteredEvents = computed (() => (showAll .value ? events .value : events .value .slice (0 , 10 )))
7164
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+ }
7574
7675onMounted (async () => {
7776 isBookmarked .value = !! bookmarksStore .bookmarks .txs .find ((t ) => t .id === props .tx .hash )
7877
7978 const data = await fetchTxMessages (props .tx .hash )
8079 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
8184})
8285
8386const handleBookmark = () => {
@@ -324,13 +327,7 @@ const handleViewRawEvent = (event) => {
324327 </Flex >
325328
326329 <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" >
334331 <Flex
335332 direction =" column"
336333 align =" center"
@@ -607,14 +604,14 @@ const handleViewRawEvent = (event) => {
607604 </Text >
608605 </Flex >
609606 </Flex >
607+
608+ <Button @click =" handleLoadMore" type =" secondary" size =" mini" :disabled =" tx.events_count == events.length" >
609+ Load More
610+ </Button >
610611 </Flex >
611612 <Flex v-if =" activeTab === 'messages'" :class =" $style.inner" >
612613 <MessagesTable :messages =" messages" />
613614 </Flex >
614-
615- <Button v-if =" events.length > 10" @click =" handleShowAll" type =" secondary" size =" mini" >
616- {{ !showAll ? "View More" : "Hide" }}
617- </Button >
618615 </Flex >
619616 </Flex >
620617 </Flex >
0 commit comments