Bimba.git

commit 17d9c71dadc4187878e4a607e804c6c240237133

Author: Adam Pioterek <adam.pioterek@protonmail.ch>

fix: empty favourite on no connection

 app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt | 7 ++++++-


diff --git a/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt b/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt
index 94610b4ae43957c92dc947112ddca7a11a6b9d1c..ee3c5ab21c3d525f85f3e52b59ab83c33f560a88 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt
@@ -121,7 +121,12 @@     fun nextDeparture() =
             if (cache.isEmpty())
                 null
             else
-                cache.flatMap { it.value }.sortedBy { it.time }[0]
+                cache.flatMap { it.value }.let {
+                    if (it.isEmpty())
+                        null
+                    else
+                        it.sortedBy { it.time }[0]
+                }
 
 
     fun fullTimetable(): Map<String, List<Departure>> {