From 2c6ed4cbcd547daca59f812154df7bf30e0159ac Mon Sep 17 00:00:00 2001 From: mikeplotean <101570226+mikeplotean@users.noreply.github.com> Date: Thu, 14 Dec 2023 10:55:34 +0200 Subject: [PATCH] chore: event-log pagination update (#41) --- .../walt/webwallet/service/SSIKit2WalletService.kt | 9 ++++----- .../web/src/pages/wallet/[wallet]/eventlog.vue | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/waltid-web-wallet/src/main/kotlin/id/walt/webwallet/service/SSIKit2WalletService.kt b/waltid-web-wallet/src/main/kotlin/id/walt/webwallet/service/SSIKit2WalletService.kt index a037dbcfe..10681704b 100644 --- a/waltid-web-wallet/src/main/kotlin/id/walt/webwallet/service/SSIKit2WalletService.kt +++ b/waltid-web-wallet/src/main/kotlin/id/walt/webwallet/service/SSIKit2WalletService.kt @@ -682,7 +682,7 @@ class SSIKit2WalletService(tenant: String?, accountId: UUID, walletId: UUID) : EventLogFilterDataResult( items = events, count = events.size, - currentStartingAfter = computeCurrentStartingAfter(startingAfterItemIndex, pageSize), + currentStartingAfter = computeCurrentStartingAfter(startingAfterItemIndex), nextStartingAfter = computeNextStartingAfter(startingAfterItemIndex, pageSize, count) ) }.fold(onSuccess = { @@ -758,14 +758,13 @@ class SSIKit2WalletService(tenant: String?, accountId: UUID, walletId: UUID) : ) //TODO: move to related entity - private fun computeCurrentStartingAfter(afterItemIndex: Long, pageSize: Int): String? = let { - val itemIndex = afterItemIndex - pageSize - itemIndex.takeIf { it >= -1 }?.toString() + private fun computeCurrentStartingAfter(afterItemIndex: Long): String? = let { + afterItemIndex.takeIf { it >= 0 }?.toString() } //TODO: move to related entity private fun computeNextStartingAfter(afterItemIndex: Long, pageSize: Int, count: Long): String? = let { val itemIndex = afterItemIndex + pageSize - itemIndex.takeIf { it <= count }?.toString() + itemIndex.takeIf { it < count }?.toString() } } \ No newline at end of file diff --git a/waltid-web-wallet/web/src/pages/wallet/[wallet]/eventlog.vue b/waltid-web-wallet/web/src/pages/wallet/[wallet]/eventlog.vue index 8750aff5f..1dd40d739 100644 --- a/waltid-web-wallet/web/src/pages/wallet/[wallet]/eventlog.vue +++ b/waltid-web-wallet/web/src/pages/wallet/[wallet]/eventlog.vue @@ -9,9 +9,9 @@