Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add user ID caching and update initial data logic in DeviceFolderVerticalGridView

AmanRajSinghMourya02a08dec3234
diff --git a/mobile/apps/photos/lib/ui/collections/device/device_folders_vertical_grid_view.dart b/mobile/apps/photos/lib/ui/collections/device/device_folders_vertical_grid_view.dart
index 1a67d4436e..c9aeb6eb35 100644
--- a/mobile/apps/photos/lib/ui/collections/device/device_folders_vertical_grid_view.dart
+++ b/mobile/apps/photos/lib/ui/collections/device/device_folders_vertical_grid_view.dart
@@ -5,6 +5,7 @@ import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
+import 'package:photos/core/configuration.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/db/device_files_db.dart';
import 'package:photos/db/files_db.dart';
@@ -105,6 +106,7 @@ class DeviceFolderVerticalGridSliver extends StatefulWidget {
class _DeviceFolderVerticalGridViewBodyState
extends State<DeviceFolderVerticalGridSliver> {
static List<DeviceCollection>? _cachedDeviceCollections;
+ static int? _cachedUserID;
StreamSubscription<BackupFoldersUpdatedEvent>? _backupFoldersUpdatedEvent;
StreamSubscription<LocalPhotosUpdatedEvent>? _localFilesSubscription;
@@ -144,10 +146,12 @@ class _DeviceFolderVerticalGridViewBodyState
}
Future<List<DeviceCollection>> _loadDeviceCollections() async {
+ final userID = Configuration.instance.getUserID();
final deviceCollections = await FilesDB.instance.getDeviceCollections(
includeCoverThumbnail: true,
);
_cachedDeviceCollections = deviceCollections;
+ _cachedUserID = userID;
return deviceCollections;
}
@@ -180,7 +184,9 @@ class _DeviceFolderVerticalGridViewBodyState
return FutureBuilder<List<DeviceCollection>>(
future: _deviceCollectionsFuture,
- initialData: _cachedDeviceCollections,
+ initialData: _cachedUserID == Configuration.instance.getUserID()
+ ? _cachedDeviceCollections
+ : null,
builder: (context, snapshot) {
if (snapshot.hasData) {
List<DeviceCollection> deviceCollections = snapshot.data!.toList();