You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jo...@apache.org on 2021/10/22 16:01:00 UTC

[isis] 02/03: ISIS-2348 replay timing improved

This is an automated email from the ASF dual-hosted git repository.

joergrade pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 2c8fe0b73e0af255fda1e72407f94ae0c6c33ad2
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Fri Oct 22 16:25:43 2021 +0200

    ISIS-2348 replay timing improved
---
 .../org/apache/isis/client/kroviz/core/event/ReplayCommand.kt  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/ReplayCommand.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/ReplayCommand.kt
index 4aa7604..5a5cb36 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/ReplayCommand.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/ReplayCommand.kt
@@ -47,10 +47,10 @@ class ReplayCommand {
         var previous: LogEntry? = null
         userActions.forEach {
             if (it.isUserAction() && previous != null) {
+                val ms = calculateDelay(previous!!, it) // needs to be outside of launch{} - or current=previous
+                val obj = it.obj as TObject
                 AppScope.launch {
-                    val ms = calculateDelay(previous!!, it)
                     delay(ms) // non-blocking delay
-                    val obj = it.obj as TObject
                     ResourceProxy().load(obj)
                 }
             } else {
@@ -62,9 +62,9 @@ class ReplayCommand {
     }
 
     private fun calculateDelay(previous: LogEntry, current: LogEntry): Long {
-        val currentMillis = current.createdAt.getTime().toLong()
-        val previousMillis = previous.createdAt.getTime().toLong()
-        return currentMillis - previousMillis
+        val currentMs = current.createdAt.getTime()
+        val previousMs = previous.createdAt.getTime()
+        return  currentMs.minus(previousMs).toLong()
     }
 
     private fun filterReplayEvents(events: List<LogEntry>): List<LogEntry> {