Ensure that MMS have unique keys

This commit is contained in:
Moez Bhatti
2018-01-05 00:09:45 -05:00
parent 20f83fccf9
commit 613e3096a2
5 changed files with 27 additions and 12 deletions
+7 -7
View File
@@ -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
*/