mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Ensure that MMS have unique keys
This commit is contained in:
@@ -32,18 +32,18 @@ class Keys @Inject constructor() {
|
||||
private var maxValue: Long = 0L
|
||||
|
||||
init {
|
||||
refresh()
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called upon initialization, and after a sync
|
||||
*/
|
||||
fun refresh() {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
maxValue = realm.where(Message::class.java).max("id")?.toLong() ?: 0L
|
||||
realm.close()
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when a new sync is being started
|
||||
*/
|
||||
fun reset() {
|
||||
maxValue = 0L
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid ID that can be used to store a new message
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user