mirror of
https://github.com/Matte23/circolapp.git
synced 2025-12-05 23:19:10 +00:00
Do not send notifications if database was empty
This commit is contained in:
@@ -59,13 +59,19 @@ class ServerUtils(databasePath: String, private val enableNotifications: Boolean
|
||||
errorCode = 1
|
||||
}
|
||||
|
||||
circularDao.insertAll(newCirculars)
|
||||
|
||||
// Do not send anything if the database was empty
|
||||
if (oldCirculars.isEmpty()) {
|
||||
print("Database was empty, not sending notifications \n")
|
||||
return Pair(emptyList(), 0)
|
||||
}
|
||||
|
||||
val oldCircularsSize =
|
||||
if (newCirculars.size < oldCirculars.size) 0 else oldCirculars.size
|
||||
|
||||
val circularCount = newCirculars.size - oldCircularsSize
|
||||
onlyNewCirculars = newCirculars.subList(0, circularCount)
|
||||
|
||||
circularDao.insertAll(newCirculars)
|
||||
}
|
||||
return Pair(onlyNewCirculars, errorCode)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ actual class DatabaseDriverFactory(private val path: String) {
|
||||
val currentVer = DatabaseFactory.getVersion(it)
|
||||
if (currentVer == 0) {
|
||||
AppDatabase.Schema.create(it)
|
||||
DatabaseFactory.setVersion(it, 1)
|
||||
DatabaseFactory.setVersion(it, AppDatabase.Schema.version)
|
||||
} else {
|
||||
val schemaVer: Int = AppDatabase.Schema.version
|
||||
if (schemaVer > currentVer) {
|
||||
|
||||
Reference in New Issue
Block a user