[App] Force full sync on update

This commit is contained in:
Kuba Szczodrzyński 2025-02-02 15:48:11 +01:00
parent aeecc48639
commit cac98ee3d4
No known key found for this signature in database
GPG Key ID: 43037AC62A600562
4 changed files with 13 additions and 1 deletions

View File

@ -241,6 +241,14 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope {
withContext(Dispatchers.Default) { withContext(Dispatchers.Default) {
config.migrate(this@App) config.migrate(this@App)
if (config.appVersionCore < BuildConfig.VERSION_CODE) {
// force syncing all endpoints on update
db.endpointTimerDao().clear()
config.sync.lastAppSync = 0L
config.hash = "invalid"
config.appVersionCore = BuildConfig.VERSION_CODE
}
SSLProviderInstaller.install(applicationContext, this@App::buildHttp) SSLProviderInstaller.install(applicationContext, this@App::buildHttp)
if (config.devModePassword != null) if (config.devModePassword != null)

View File

@ -43,6 +43,7 @@ class Config(db: AppDb) : BaseConfig(db) {
var appInstalledTime by config<Long>(0L) var appInstalledTime by config<Long>(0L)
var appRateSnackbarTime by config<Long>(0L) var appRateSnackbarTime by config<Long>(0L)
var appVersion by config<Int>(BuildConfig.VERSION_CODE) var appVersion by config<Int>(BuildConfig.VERSION_CODE)
var appVersionCore by config<Int>(0)
var validation by config<String?>(null, "buildValidation") var validation by config<String?>(null, "buildValidation")
var archiverEnabled by config<Boolean>(true) var archiverEnabled by config<Boolean>(true)

View File

@ -206,7 +206,7 @@ class SzkolnyApi(val app: App) : CoroutineScope {
teams.filter { it.profileId == profile.id }.map { it.code } teams.filter { it.profileId == profile.id }.map { it.code }
) )
val hash = user.toString().md5() val hash = user.toString().md5()
if (hash == profile.config.hash) if (hash == profile.config.hash && app.config.hash != "invalid")
return@mapNotNull null return@mapNotNull null
return@mapNotNull user to profile.config return@mapNotNull user to profile.config
} }

View File

@ -24,4 +24,7 @@ interface EndpointTimerDao {
@Query("DELETE FROM endpointTimers WHERE profileId = :profileId") @Query("DELETE FROM endpointTimers WHERE profileId = :profileId")
fun clear(profileId: Int) fun clear(profileId: Int)
@Query("DELETE FROM endpointTimers")
fun clear()
} }