mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
Fix backup not resuming after closed and reopen (#266)
* Fixed app not resuming backup after closing and reopening the app * Fixed cosmetic effect of backup button doesn't change state right away after pressing start backup * Fixed grammar * Fixed deep copy problem that cause incorrect asset count when backing up * Format code
This commit is contained in:
parent
d02b97e1c1
commit
40a8115101
63 changed files with 677 additions and 300 deletions
|
|
@ -16,7 +16,8 @@ class AlbumPreviewPage extends HookConsumerWidget {
|
|||
final assets = useState<List<AssetEntity>>([]);
|
||||
|
||||
_getAssetsInAlbum() async {
|
||||
assets.value = await album.getAssetListRange(start: 0, end: album.assetCount);
|
||||
assets.value =
|
||||
await album.getAssetListRange(start: 0, end: album.assetCount);
|
||||
}
|
||||
|
||||
useEffect(() {
|
||||
|
|
@ -37,7 +38,10 @@ class AlbumPreviewPage extends HookConsumerWidget {
|
|||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Text(
|
||||
"ID ${album.id}",
|
||||
style: TextStyle(fontSize: 10, color: Colors.grey[600], fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -55,8 +59,9 @@ class AlbumPreviewPage extends HookConsumerWidget {
|
|||
),
|
||||
itemCount: assets.value.length,
|
||||
itemBuilder: (context, index) {
|
||||
Future<Uint8List?> thumbData =
|
||||
assets.value[index].thumbnailDataWithSize(const ThumbnailSize(200, 200), quality: 50);
|
||||
Future<Uint8List?> thumbData = assets.value[index]
|
||||
.thumbnailDataWithSize(const ThumbnailSize(200, 200),
|
||||
quality: 50);
|
||||
|
||||
return FutureBuilder<Uint8List?>(
|
||||
future: thumbData,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
final excludedBackupAlbums = ref.watch(backupProvider).excludedBackupAlbums;
|
||||
|
||||
useEffect(() {
|
||||
ref.read(backupProvider.notifier).getBackupAlbumsInfo();
|
||||
ref.read(backupProvider.notifier).getBackupInfo();
|
||||
return null;
|
||||
}, []);
|
||||
|
||||
|
|
@ -37,8 +37,12 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
itemBuilder: ((context, index) {
|
||||
var thumbnailData = availableAlbums[index].thumbnailData;
|
||||
return Padding(
|
||||
padding: index == 0 ? const EdgeInsets.only(left: 16.00) : const EdgeInsets.all(0),
|
||||
child: AlbumInfoCard(imageData: thumbnailData, albumInfo: availableAlbums[index].albumEntity),
|
||||
padding: index == 0
|
||||
? const EdgeInsets.only(left: 16.00)
|
||||
: const EdgeInsets.all(0),
|
||||
child: AlbumInfoCard(
|
||||
imageData: thumbnailData,
|
||||
albumInfo: availableAlbums[index].albumEntity),
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
|
@ -67,10 +71,14 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
onTap: removeSelection,
|
||||
child: Chip(
|
||||
visualDensity: VisualDensity.compact,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
label: Text(
|
||||
album.name,
|
||||
style: const TextStyle(fontSize: 10, color: Colors.white, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
deleteIconColor: Colors.white,
|
||||
|
|
@ -88,7 +96,9 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
_buildExcludedAlbumNameChip() {
|
||||
return excludedBackupAlbums.map((album) {
|
||||
void removeSelection() {
|
||||
ref.watch(backupProvider.notifier).removeExcludedAlbumForBackup(album);
|
||||
ref
|
||||
.watch(backupProvider.notifier)
|
||||
.removeExcludedAlbumForBackup(album);
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
|
|
@ -97,10 +107,14 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: Chip(
|
||||
visualDensity: VisualDensity.compact,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
label: Text(
|
||||
album.name,
|
||||
style: const TextStyle(fontSize: 10, color: Colors.white, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
backgroundColor: Colors.red[300],
|
||||
deleteIconColor: Colors.white,
|
||||
|
|
@ -142,7 +156,10 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Wrap(
|
||||
children: [..._buildSelectedAlbumNameChip(), ..._buildExcludedAlbumNameChip()],
|
||||
children: [
|
||||
..._buildSelectedAlbumNameChip(),
|
||||
..._buildExcludedAlbumNameChip()
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
|
@ -165,10 +182,17 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
visualDensity: VisualDensity.compact,
|
||||
title: Text(
|
||||
"Total unique assets",
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Colors.grey[700]),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.grey[700]),
|
||||
),
|
||||
trailing: Text(
|
||||
ref.watch(backupProvider).allUniqueAssets.length.toString(),
|
||||
ref
|
||||
.watch(backupProvider)
|
||||
.allUniqueAssets
|
||||
.length
|
||||
.toString(),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
|
|
@ -206,7 +230,8 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
elevation: 5,
|
||||
title: Text(
|
||||
'Selection Info',
|
||||
|
|
@ -221,7 +246,8 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
|
|||
children: [
|
||||
Text(
|
||||
'Assets can scatter across multiple albums. Thus, albums can be included or excluded during the backup process.',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
|
||||
style: TextStyle(
|
||||
fontSize: 14, color: Colors.grey[700]),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||
|
||||
useEffect(() {
|
||||
if (backupState.backupProgress != BackUpProgressEnum.inProgress) {
|
||||
ref.read(backupProvider.notifier).getBackupInfo();
|
||||
ref.watch(backupProvider.notifier).getBackupInfo();
|
||||
}
|
||||
|
||||
ref
|
||||
|
|
@ -112,13 +112,15 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||
),
|
||||
),
|
||||
onPressed: () {
|
||||
isAutoBackup
|
||||
? ref
|
||||
.watch(authenticationProvider.notifier)
|
||||
.setAutoBackup(false)
|
||||
: ref
|
||||
.watch(authenticationProvider.notifier)
|
||||
.setAutoBackup(true);
|
||||
if (isAutoBackup) {
|
||||
ref
|
||||
.read(authenticationProvider.notifier)
|
||||
.setAutoBackup(false);
|
||||
} else {
|
||||
ref
|
||||
.read(authenticationProvider.notifier)
|
||||
.setAutoBackup(true);
|
||||
}
|
||||
},
|
||||
child: Text("Turn $backupBtnText Backup",
|
||||
style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
|
|
@ -212,7 +214,7 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Albums to be backup",
|
||||
"Albums to be backed up",
|
||||
style: TextStyle(color: Color(0xFF808080), fontSize: 12),
|
||||
),
|
||||
_buildSelectedAlbumName(),
|
||||
|
|
@ -282,14 +284,12 @@ class BackupControllerPage extends HookConsumerWidget {
|
|||
),
|
||||
BackupInfoCard(
|
||||
title: "Backup",
|
||||
subtitle:
|
||||
"Photos and videos from selected albums that are backup",
|
||||
subtitle: "Backed up photos and videos",
|
||||
info: "${backupState.selectedAlbumsBackupAssetsIds.length}",
|
||||
),
|
||||
BackupInfoCard(
|
||||
title: "Remainder",
|
||||
subtitle:
|
||||
"Photos and videos that has not been backing up from selected albums",
|
||||
subtitle: "Remaining photos and albums to back up from selection",
|
||||
info:
|
||||
"${backupState.allUniqueAssets.length - backupState.selectedAlbumsBackupAssetsIds.length}",
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue