forked from immich-app/immich
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mobile): clear local storage option (immich-app#4635)
* feat(mobile): clear local storage option * en json
- Loading branch information
1 parent
e47a11b
commit aefd052
Showing
4 changed files
with
101 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
mobile/lib/modules/settings/ui/local_storage_settings/local_storage_settings.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart' show useEffect, useState; | ||
import 'package:immich_mobile/modules/backup/models/duplicated_asset.model.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:immich_mobile/shared/providers/db.provider.dart'; | ||
|
||
class LocalStorageSettings extends HookConsumerWidget { | ||
const LocalStorageSettings({super.key}); | ||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final isarDb = ref.watch(dbProvider); | ||
final cacheItemCount = useState(0); | ||
useEffect( | ||
() { | ||
cacheItemCount.value = isarDb.duplicatedAssets.countSync(); | ||
return null; | ||
}, | ||
[], | ||
); | ||
|
||
void clearCache() { | ||
isarDb.writeTxnSync(() => isarDb.duplicatedAssets.clearSync()); | ||
cacheItemCount.value = isarDb.duplicatedAssets.countSync(); | ||
} | ||
|
||
return ExpansionTile( | ||
textColor: Theme.of(context).primaryColor, | ||
title: const Text( | ||
"cache_settings_tile_title", | ||
style: TextStyle( | ||
fontWeight: FontWeight.bold, | ||
), | ||
).tr(), | ||
subtitle: const Text( | ||
"cache_settings_tile_subtitle", | ||
style: TextStyle( | ||
fontSize: 13, | ||
), | ||
).tr(), | ||
children: [ | ||
ListTile( | ||
title: Text( | ||
"Duplicated Assets (${cacheItemCount.value})", | ||
style: Theme.of(context) | ||
.textTheme | ||
.labelLarge | ||
?.copyWith(fontWeight: FontWeight.bold), | ||
).tr(), | ||
subtitle: const Text( | ||
"Photos and videos that are black listed by the app", | ||
style: TextStyle( | ||
fontSize: 13, | ||
), | ||
).tr(), | ||
trailing: TextButton( | ||
onPressed: cacheItemCount.value > 0 ? clearCache : null, | ||
child: Text( | ||
"CLEAR", | ||
style: TextStyle( | ||
fontSize: 12, | ||
color: cacheItemCount.value > 0 ? Colors.red : Colors.grey, | ||
fontWeight: FontWeight.bold, | ||
), | ||
).tr(), | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters