0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-11 02:23:09 -05:00

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

* fix(mobile): simplify album selection backup state management

* remove search bar'

* log available albums
This commit is contained in:
Alex 2023-12-12 21:06:04 -06:00 committed by GitHub
parent f7429c3615
commit 885eba2b7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 50 deletions

View file

@ -169,4 +169,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 599d8aeb73728400c15364e734525722250a5382 PODFILE CHECKSUM: 599d8aeb73728400c15364e734525722250a5382
COCOAPODS: 1.12.1 COCOAPODS: 1.11.3

View file

@ -255,7 +255,6 @@ class BackupNotifier extends StateNotifier<BackUpState> {
albumMap[album.id] = album; albumMap[album.id] = album;
} }
} }
state = state.copyWith(availableAlbums: availableAlbums); state = state.copyWith(availableAlbums: availableAlbums);
final List<BackupAlbum> excludedBackupAlbums = final List<BackupAlbum> excludedBackupAlbums =
@ -295,6 +294,9 @@ class BackupNotifier extends StateNotifier<BackUpState> {
excludedBackupAlbums: excludedAlbums, excludedBackupAlbums: excludedAlbums,
); );
log.info(
"_getBackupAlbumsInfo: Found ${availableAlbums.length} available albums",
);
debugPrint("_getBackupAlbumsInfo takes ${stopwatch.elapsedMilliseconds}ms"); debugPrint("_getBackupAlbumsInfo takes ${stopwatch.elapsedMilliseconds}ms");
} }

View file

@ -17,12 +17,7 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
final selectedBackupAlbums = ref.watch(backupProvider).selectedBackupAlbums; final selectedBackupAlbums = ref.watch(backupProvider).selectedBackupAlbums;
final excludedBackupAlbums = ref.watch(backupProvider).excludedBackupAlbums; final excludedBackupAlbums = ref.watch(backupProvider).excludedBackupAlbums;
final isDarkTheme = context.isDarkTheme; final isDarkTheme = context.isDarkTheme;
final allAlbums = ref.watch(backupProvider).availableAlbums; final albums = 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;
useEffect( useEffect(
() { () {
@ -153,47 +148,47 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
}).toSet(); }).toSet();
} }
buildSearchBar() { // buildSearchBar() {
return Padding( // return Padding(
padding: const EdgeInsets.only(left: 16.0, right: 16, bottom: 8.0), // padding: const EdgeInsets.only(left: 16.0, right: 16, bottom: 8.0),
child: TextFormField( // child: TextFormField(
onChanged: (searchValue) { // onChanged: (searchValue) {
if (searchValue.isEmpty) { // // if (searchValue.isEmpty) {
filteredAlbums.value = allAlbums; // // albums = availableAlbums;
} else { // // } else {
filteredAlbums.value = allAlbums // // albums.value = availableAlbums
.where( // // .where(
(album) => album.name // // (album) => album.name
.toLowerCase() // // .toLowerCase()
.contains(searchValue.toLowerCase()), // // .contains(searchValue.toLowerCase()),
) // // )
.toList(); // // .toList();
} // // }
}, // },
decoration: InputDecoration( // decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric( // contentPadding: const EdgeInsets.symmetric(
horizontal: 8.0, // horizontal: 8.0,
vertical: 8.0, // vertical: 8.0,
), // ),
hintText: "Search", // hintText: "Search",
hintStyle: TextStyle( // hintStyle: TextStyle(
color: isDarkTheme ? Colors.white : Colors.grey, // color: isDarkTheme ? Colors.white : Colors.grey,
fontSize: 14.0, // fontSize: 14.0,
), // ),
prefixIcon: const Icon( // prefixIcon: const Icon(
Icons.search, // Icons.search,
color: Colors.grey, // color: Colors.grey,
), // ),
border: OutlineInputBorder( // border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10), // borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none, // borderSide: BorderSide.none,
), // ),
filled: true, // filled: true,
fillColor: isDarkTheme ? Colors.white30 : Colors.grey[200], // fillColor: isDarkTheme ? Colors.white30 : Colors.grey[200],
), // ),
), // ),
); // );
} // }
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
@ -301,7 +296,7 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
), ),
), ),
buildSearchBar(), // buildSearchBar(),
], ],
), ),
), ),