Skip to content

Commit

Permalink
fix: Don't use .all { } if the list is empty, it will always return…
Browse files Browse the repository at this point in the history
… `true` (#1522)
  • Loading branch information
KevinBoulongne authored Feb 11, 2025
2 parents 61d4427 + 99c351c commit f6277b2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Core
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object DriveInfosController {
.modules(RealmModules.DriveFilesModule())
.build()

fun getRealmInstance() = Realm.getInstance(realmConfiguration)
fun getRealmInstance(): Realm = Realm.getInstance(realmConfiguration)

private fun ArrayList<Drive>.initDriveForRealm(
drive: Drive,
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/com/infomaniak/drive/ui/LaunchActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ class LaunchActivity : AppCompatActivity() {
AccountUtils.updateCurrentUserAndDrives(this)
}

val areAllDrivesInMaintenance = DriveInfosController.getDrives(userId = AccountUtils.currentUserId).all { it.maintenance }
val areAllDrivesInMaintenance = DriveInfosController.getDrives(userId = AccountUtils.currentUserId)
.takeUnless { it.isEmpty() }
?.all { it.maintenance }
?: false

return when {
areAllDrivesInMaintenance -> MaintenanceActivity::class.java
else -> MainActivity::class.java
return if (areAllDrivesInMaintenance) {
MaintenanceActivity::class.java
} else {
MainActivity::class.java
}
}

Expand Down
2 changes: 1 addition & 1 deletion fastlane/metadata/android/fr/changelogs/5_03_003_01.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Correctement déconnecte l'utilisateur si son token expire
- Déconnecte correctement l'utilisateur si son token expire

0 comments on commit f6277b2

Please sign in to comment.