Skip to content

High performance self-hosted photo and video management solution.

fix(mobile): simplify state management in backup selection page (#5655)

Alex885eba2b7c1f
diff --git a/mobile/ios/Podfile.lock b/mobile/ios/Podfile.lock
index c6c23d942a..75168ce1c9 100644
--- a/mobile/ios/Podfile.lock
+++ b/mobile/ios/Podfile.lock
@@ -169,4 +169,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 599d8aeb73728400c15364e734525722250a5382
-COCOAPODS: 1.12.1
+COCOAPODS: 1.11.3
diff --git a/mobile/lib/modules/backup/providers/backup.provider.dart b/mobile/lib/modules/backup/providers/backup.provider.dart
index 2d5f6e3b7c..a175a17de1 100644
--- a/mobile/lib/modules/backup/providers/backup.provider.dart
+++ b/mobile/lib/modules/backup/providers/backup.provider.dart
@@ -255,7 +255,6 @@ class BackupNotifier extends StateNotifier<BackUpState> {
albumMap[album.id] = album;
}
}
-
state = state.copyWith(availableAlbums: availableAlbums);
final List<BackupAlbum> excludedBackupAlbums =
@@ -295,6 +294,9 @@ class BackupNotifier extends StateNotifier<BackUpState> {
excludedBackupAlbums: excludedAlbums,
);
+ log.info(
+ "_getBackupAlbumsInfo: Found ${availableAlbums.length} available albums",
+ );
debugPrint("_getBackupAlbumsInfo takes ${stopwatch.elapsedMilliseconds}ms");
}
diff --git a/mobile/lib/modules/backup/views/backup_album_selection_page.dart b/mobile/lib/modules/backup/views/backup_album_selection_page.dart
index 96ed879ac1..4c2708ab09 100644
--- a/mobile/lib/modules/backup/views/backup_album_selection_page.dart
+++ b/mobile/lib/modules/backup/views/backup_album_selection_page.dart
@@ -17,12 +17,7 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
final selectedBackupAlbums = ref.watch(backupProvider).selectedBackupAlbums;
final excludedBackupAlbums = ref.watch(backupProvider).excludedBackupAlbums;
final isDarkTheme = context.isDarkTheme;
- final allAlbums = ref.watch(backupProvider).availableAlbums;
-
- // Albums which are displayed to the user
- // by filtering out based on search
- final filteredAlbums = useState(allAlbums);
- final albums = filteredAlbums.value;
+ final albums = ref.watch(backupProvider).availableAlbums;
useEffect(
() {
@@ -153,47 +148,47 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
}).toSet();
}
- buildSearchBar() {
- return Padding(
- padding: const EdgeInsets.only(left: 16.0, right: 16, bottom: 8.0),
- child: TextFormField(
- onChanged: (searchValue) {
- if (searchValue.isEmpty) {
- filteredAlbums.value = allAlbums;
- } else {
- filteredAlbums.value = allAlbums
- .where(
- (album) => album.name
- .toLowerCase()
- .contains(searchValue.toLowerCase()),
- )
- .toList();
- }
- },
- decoration: InputDecoration(
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 8.0,
- vertical: 8.0,
- ),
- hintText: "Search",
- hintStyle: TextStyle(
- color: isDarkTheme ? Colors.white : Colors.grey,
- fontSize: 14.0,
- ),
- prefixIcon: const Icon(
- Icons.search,
- color: Colors.grey,
- ),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(10),
- borderSide: BorderSide.none,
- ),
- filled: true,
- fillColor: isDarkTheme ? Colors.white30 : Colors.grey[200],
- ),
- ),
- );
- }
+ // buildSearchBar() {
+ // return Padding(
+ // padding: const EdgeInsets.only(left: 16.0, right: 16, bottom: 8.0),
+ // child: TextFormField(
+ // onChanged: (searchValue) {
+ // // if (searchValue.isEmpty) {
+ // // albums = availableAlbums;
+ // // } else {
+ // // albums.value = availableAlbums
+ // // .where(
+ // // (album) => album.name
+ // // .toLowerCase()
+ // // .contains(searchValue.toLowerCase()),
+ // // )
+ // // .toList();
+ // // }
+ // },
+ // decoration: InputDecoration(
+ // contentPadding: const EdgeInsets.symmetric(
+ // horizontal: 8.0,
+ // vertical: 8.0,
+ // ),
+ // hintText: "Search",
+ // hintStyle: TextStyle(
+ // color: isDarkTheme ? Colors.white : Colors.grey,
+ // fontSize: 14.0,
+ // ),
+ // prefixIcon: const Icon(
+ // Icons.search,
+ // color: Colors.grey,
+ // ),
+ // border: OutlineInputBorder(
+ // borderRadius: BorderRadius.circular(10),
+ // borderSide: BorderSide.none,
+ // ),
+ // filled: true,
+ // fillColor: isDarkTheme ? Colors.white30 : Colors.grey[200],
+ // ),
+ // ),
+ // );
+ // }
return Scaffold(
appBar: AppBar(
@@ -301,7 +296,7 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
),
),
- buildSearchBar(),
+ // buildSearchBar(),
],
),
),