remove non-total methods

This commit is contained in:
Evgeny Poberezkin
2025-08-11 08:49:40 +01:00
parent 68aeb12387
commit d669c1ee62
2 changed files with 9 additions and 6 deletions

View File

@@ -474,14 +474,17 @@ object ChatModel {
}
fun removeLastChatItems() {
val removed: Triple<Long, Int, Boolean>
val remIndex: Int
val rem: ChatItem?
chatItems.value = SnapshotStateList<ChatItem>().apply {
addAll(chatItems.value)
val remIndex = lastIndex
val rem = removeLast()
removed = Triple(rem.id, remIndex, rem.isRcvNew)
remIndex = lastIndex
rem = removeLastOrNull()
}
if (rem != null) {
val removed = Triple(rem.id, remIndex, rem.isRcvNew)
chatState.itemsRemoved(listOf(removed), chatItems.value)
}
chatState.itemsRemoved(listOf(removed), chatItems.value)
}
suspend fun addChatItem(rhId: Long?, chatInfo: ChatInfo, cItem: ChatItem) {

View File

@@ -32,7 +32,7 @@ val databaseBackend: String = if (appPlatform == AppPlatform.ANDROID) "sqlite" e
class FifoQueue<E>(private var capacity: Int) : LinkedList<E>() {
override fun add(element: E): Boolean {
if(size > capacity) removeFirst()
if (size > capacity) removeFirstOrNull()
return super.add(element)
}
}