mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-15 20:09:19 +00:00
Update: Clean up DB's cleanUp
This commit is contained in:
@ -62,19 +62,19 @@ abstract class DatabaseX : RoomDatabase() {
|
|||||||
|
|
||||||
fun cleanUp(pairs: Set<Pair<Long, Boolean>>) {
|
fun cleanUp(pairs: Set<Pair<Long, Boolean>>) {
|
||||||
runInTransaction {
|
runInTransaction {
|
||||||
val result = pairs.windowed(10, 10, true).map {
|
pairs.windowed(10, 10, true).map {
|
||||||
val ids = it.map { it.first }.toLongArray()
|
it.map { it.first }
|
||||||
val productsCount = productDao.deleteById(*ids)
|
.toLongArray()
|
||||||
val categoriesCount = categoryDao.deleteById(*ids)
|
.forEach { id ->
|
||||||
val deleteIds = it.filter { it.second }.map { it.first }.toLongArray()
|
productDao.deleteById(id)
|
||||||
repositoryDao.deleteById(*deleteIds)
|
categoryDao.deleteById(id)
|
||||||
productsCount != 0 || categoriesCount != 0
|
}
|
||||||
|
it.filter { it.second }
|
||||||
|
.map { it.first }
|
||||||
|
.toLongArray()
|
||||||
|
.forEach { id -> repositoryDao.deleteById(id) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO Use live objects and observers instead
|
|
||||||
/*if (result.any { it }) {
|
|
||||||
com.looker.droidify.database.Database.notifyChanged(com.looker.droidify.database.Database.Subject.Products)
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun finishTemporary(repository: com.looker.droidify.entity.Repository, success: Boolean) {
|
fun finishTemporary(repository: com.looker.droidify.entity.Repository, success: Boolean) {
|
||||||
|
Reference in New Issue
Block a user