Fixed adding of new call to call history

This commit is contained in:
Juha Heinanen
2025-10-02 08:23:56 +03:00
parent dc0112648e
commit 4b89c0e7e2
@@ -19,20 +19,12 @@ class CallHistoryNew(val aor: String, val peerUri: String, val direction: String
fun add() { fun add() {
BaresipService.callHistory.add(this) BaresipService.callHistory.add(this)
var count = 0 var aorSpecificHistory = BaresipService.callHistory.filter { it.aor == this.aor }
var remove: CallHistoryNew? = null if (aorSpecificHistory.size > CALL_HISTORY_SIZE) {
for (h in BaresipService.callHistory) val oldestToRemove = aorSpecificHistory.first()
if (h.aor == this.aor) { if (oldestToRemove.recording[0].isNotEmpty())
count++ deleteRecording(oldestToRemove.recording)
if (count > CALL_HISTORY_SIZE) { BaresipService.callHistory.remove(oldestToRemove)
remove = h
break
}
}
if (remove != null) {
if (remove.recording[0] != "")
deleteRecording(remove.recording)
BaresipService.callHistory.remove(remove)
} }
save() save()
} }