Show warning when enabling autoDelete

This commit is contained in:
Moez Bhatti
2020-12-22 00:00:42 -05:00
parent 0cfca58350
commit b087de8f73
7 changed files with 54 additions and 4 deletions
@@ -66,8 +66,11 @@ import java.io.File
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.IOException
import java.util.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.collections.ArrayList
import kotlin.math.sqrt
@Singleton
@@ -724,4 +727,14 @@ class MessageRepositoryImpl @Inject constructor(
}
}
}
override fun getOldMessageCounts(maxAgeDays: Int): Map<Long, Int> {
return Realm.getDefaultInstance().use { realm ->
realm.where(Message::class.java)
.lessThan("date", now() - TimeUnit.DAYS.toMillis(maxAgeDays.toLong()))
.findAll()
.groupingBy { message -> message.threadId }
.eachCount()
}
}
}