Skip to content

Commit 65b76fe

Browse files
committed
Triggers for invalid access
1 parent 763a298 commit 65b76fe

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

app/src/main/java/com/forcetower/uefs/core/storage/database/dao/AccessDao.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ abstract class AccessDao {
5959
@Query("UPDATE Access SET valid = :valid")
6060
abstract fun setAccessValidation(valid: Boolean)
6161

62+
@Query("UPDATE Access SET valid = :valid")
63+
abstract suspend fun setAccessValidationDirect(valid: Boolean)
64+
6265
@Query("UPDATE Access SET password = :password")
6366
abstract fun updateAccessPassword(password: String)
6467

app/src/main/java/com/forcetower/uefs/core/storage/repository/SnowpiercerSyncRepository.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import com.forcetower.uefs.core.task.definers.SemestersProcessor
4343
import com.forcetower.uefs.core.util.VersionUtils
4444
import com.forcetower.uefs.service.NotificationCreator
4545
import com.google.firebase.crashlytics.FirebaseCrashlytics
46+
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
4647
import dev.forcetower.breaker.Orchestra
4748
import dev.forcetower.breaker.model.Authorization
4849
import dev.forcetower.breaker.model.Person
@@ -64,7 +65,8 @@ class SnowpiercerSyncRepository @Inject constructor(
6465
@Named("webViewUA") agent: String,
6566
private val context: Context,
6667
private val database: UDatabase,
67-
private val preferences: SharedPreferences
68+
private val preferences: SharedPreferences,
69+
private val remoteConfig: FirebaseRemoteConfig
6870
) {
6971
private val orchestra = Orchestra.Builder().client(client).userAgent(agent).build()
7072

@@ -192,9 +194,12 @@ class SnowpiercerSyncRepository @Inject constructor(
192194
return database.profileDao().insert(person)
193195
}
194196

195-
private fun onAccessInvalided() {
196-
database.accessDao().setAccessValidation(false)
197-
NotificationCreator.showInvalidAccessNotification(context)
197+
private suspend fun onAccessInvalided() {
198+
val access = database.accessDao().getAccessDirectSuspend() ?: return
199+
database.accessDao().setAccessValidationDirect(false)
200+
if (access.valid && remoteConfig.getBoolean("show_access_invalidation_notification")) {
201+
NotificationCreator.showInvalidAccessNotification(context)
202+
}
198203
}
199204

200205
private suspend fun findAndMatch() {

0 commit comments

Comments
 (0)