From 885eba2b7c1fc19d5a819199b47df4923d9478b7 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 12 Dec 2023 21:06:04 -0600 Subject: [PATCH] fix(mobile): simplify state management in backup selection page (#5655) * fix(mobile): simplify album selection backup state management * remove search bar' * log available albums --- mobile/ios/Podfile.lock | 2 +- .../backup/providers/backup.provider.dart | 4 +- .../views/backup_album_selection_page.dart | 91 +++++++++---------- 3 files changed, 47 insertions(+), 50 deletions(-) diff --git a/mobile/ios/Podfile.lock b/mobile/ios/Podfile.lock index c6c23d942..75168ce1c 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 2d5f6e3b7..a175a17de 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 { albumMap[album.id] = album; } } - state = state.copyWith(availableAlbums: availableAlbums); final List excludedBackupAlbums = @@ -295,6 +294,9 @@ class BackupNotifier extends StateNotifier { 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 96ed879ac..4c2708ab0 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(), ], ), ),