diff --git a/lib/ui/viewer/gallery/device_folder_page.dart b/lib/ui/viewer/gallery/device_folder_page.dart index 25ec0b3ca..840845acf 100644 --- a/lib/ui/viewer/gallery/device_folder_page.dart +++ b/lib/ui/viewer/gallery/device_folder_page.dart @@ -87,12 +87,19 @@ class BackupHeaderWidget extends StatefulWidget { } class _BackupHeaderWidgetState extends State { + late Future> filesInDeviceCollection; + late ValueNotifier shouldBackup; + @override + void initState() { + shouldBackup = ValueNotifier(widget.deviceCollection.shouldBackup); + + super.initState(); + } + @override Widget build(BuildContext context) { - final Future> filesInDeviceCollection = - _filesInDeviceCollection(); - final ValueNotifier shouldBackup = - ValueNotifier(widget.deviceCollection.shouldBackup); + filesInDeviceCollection = _filesInDeviceCollection(); + final colorScheme = getEnteColorScheme(context); return Padding( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 20), @@ -114,7 +121,11 @@ class _BackupHeaderWidgetState extends State { .updateDeviceFolderSyncStatus( {widget.deviceCollection.id: !shouldBackup.value}, ).then( - (val) => shouldBackup.value = !shouldBackup.value, + (val) { + setState(() { + shouldBackup.value = !shouldBackup.value; + }); + }, onError: (e) { Logger("BackupHeaderWidget").severe( "Could not update device folder sync status", @@ -138,7 +149,9 @@ class _BackupHeaderWidgetState extends State { future: _hasIgnoredFiles(filesInDeviceCollection), builder: (context, snapshot) { Widget child; - if (snapshot.hasData && snapshot.data as bool) { + if (snapshot.hasData && + snapshot.data as bool && + shouldBackup.value) { child = Column( children: [ const SizedBox(height: 24),