Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add safety check

ashilkn4d26de8ffd31
diff --git a/mobile/lib/services/album_home_widget_service.dart b/mobile/lib/services/album_home_widget_service.dart
index 652f99de27..4bf8864940 100644
--- a/mobile/lib/services/album_home_widget_service.dart
+++ b/mobile/lib/services/album_home_widget_service.dart
@@ -414,6 +414,9 @@ class AlbumHomeWidgetService {
while (renderedCount < limit && attemptsCount < maxAttempts) {
final randomEntry =
albumsWithFilesEntries[random.nextInt(albumsWithFilesLength)];
+
+ if (randomEntry.value.$2.isEmpty) continue;
+
final randomAlbumFile = randomEntry.value.$2.elementAt(
random.nextInt(randomEntry.value.$2.length),
);
diff --git a/mobile/lib/services/memory_home_widget_service.dart b/mobile/lib/services/memory_home_widget_service.dart
index 4e6e2ab9b3..c015dd0a69 100644
--- a/mobile/lib/services/memory_home_widget_service.dart
+++ b/mobile/lib/services/memory_home_widget_service.dart
@@ -320,6 +320,9 @@ class MemoryHomeWidgetService {
while (renderedCount < limit && attemptsCount < maxAttempts) {
final randomEntry =
memoriesWithFilesEntries[random.nextInt(memoriesWithFilesLength)];
+
+ if (randomEntry.value.isEmpty) continue;
+
final randomMemoryFile = randomEntry.value.elementAt(
random.nextInt(randomEntry.value.length),
);
diff --git a/mobile/lib/services/people_home_widget_service.dart b/mobile/lib/services/people_home_widget_service.dart
index 6b13ce0df6..ee758caac0 100644
--- a/mobile/lib/services/people_home_widget_service.dart
+++ b/mobile/lib/services/people_home_widget_service.dart
@@ -393,6 +393,9 @@ class PeopleHomeWidgetService {
while (renderedCount < limit && attemptsCount < maxAttempts) {
final randomEntry =
peopleWithFilesEntries[random.nextInt(peopleWithFilesLength)];
+
+ if (randomEntry.value.$2.isEmpty) continue;
+
final randomPersonFile = randomEntry.value.$2.elementAt(
random.nextInt(randomEntry.value.$2.length),
);