properly store sent messages in local db
This commit is contained in:
parent
733428da38
commit
e116c5baa8
|
@ -704,7 +704,13 @@ class ThreadActivity : SimpleActivity() {
|
||||||
notificationManager.cancel(threadId.hashCode())
|
notificationManager.cancel(threadId.hashCode())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val lastMaxId = messages.maxByOrNull { it.id }?.id ?: 0L
|
||||||
messages = getMessages(threadId)
|
messages = getMessages(threadId)
|
||||||
|
|
||||||
|
messages.filter { !it.isReceivedMessage() && it.id > lastMaxId }.forEach {
|
||||||
|
messagesDB.insertOrIgnore(it)
|
||||||
|
}
|
||||||
|
|
||||||
setupAdapter()
|
setupAdapter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ interface MessagesDao {
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
fun insertOrUpdate(message: Message)
|
fun insertOrUpdate(message: Message)
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
|
fun insertOrIgnore(message: Message): Long
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
fun insertMessages(vararg message: Message)
|
fun insertMessages(vararg message: Message)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue