Skip to content

Commit

Permalink
fix: Handling negative time values in chat log formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
magge-faf authored and Brutus5000 committed Aug 19, 2023
1 parent 08a82df commit 1e9cc05
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,20 @@ private void showChatLog(ModerationReportFX report) {

ReplayDataParser replayDataParser = new ReplayDataParser(tempFilePath, objectMapper);
String chatLog = header + replayDataParser.getChatMessages().stream()
.map(message -> format("[{0}] from {1} to {2}: {3}",
DurationFormatUtils.formatDuration(message.getTime().toMillis(), "HH:mm:ss"),
message.getSender(), message.getReceiver(), message.getMessage()))
.map(message -> {
long timeMillis = message.getTime().toMillis();
String formattedTime;

if (timeMillis >= 0) {
formattedTime = DurationFormatUtils.formatDuration(timeMillis, "HH:mm:ss");
} else {
formattedTime = "N/A"; // replay data contains negative timestamps for whatever reason
}

return format("[{0}] from {1} to {2}: {3}",
formattedTime,
message.getSender(), message.getReceiver(), message.getMessage());
})
.collect(Collectors.joining("\n"));

chatLogTextArea.setText(chatLog);
Expand Down

0 comments on commit 1e9cc05

Please sign in to comment.