Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkondratek committed Apr 4, 2024
1 parent 6a5d236 commit a912047
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/kotlin/com/sourcegraph/cody/history/HistoryService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ class HistoryService(private val project: Project) :
val found = getOrCreateChat(internalId)
if (found.messages.size < chatMessages.size) {
found.setUpdatedTimeAt(LocalDateTime.now())
found.messages = chatMessages.map(::convertToMessageState).toMutableList()
synchronized(listeners) { listeners.forEach { it(found) } }
}

chatMessages.map(::convertToMessageState).forEachIndexed { index, messageState ->
val messageToUpdate = found.messages.getOrNull(index)
if (messageToUpdate != null) {
found.messages[index] = messageState
} else {
found.messages.add(messageState)
}
}
synchronized(listeners) { listeners.forEach { it(found) } }
}

@Synchronized
Expand Down

0 comments on commit a912047

Please sign in to comment.