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`
  • Loading branch information
KevinBoulongne committed Feb 11, 2025
1 parent 8aba6c1 commit bf14be9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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

0 comments on commit bf14be9

Please sign in to comment.