handle ingore iCloud asset upload'
This commit is contained in:
parent
0bc3dd238b
commit
fdc5349059
4 changed files with 42 additions and 2 deletions
|
@ -10,6 +10,8 @@ import 'package:immich_mobile/modules/backup/models/backup_album.model.dart';
|
|||
import 'package:immich_mobile/modules/backup/models/current_upload_asset.model.dart';
|
||||
import 'package:immich_mobile/modules/backup/models/duplicated_asset.model.dart';
|
||||
import 'package:immich_mobile/modules/backup/models/error_upload_asset.model.dart';
|
||||
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
|
||||
import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
|
||||
import 'package:immich_mobile/shared/models/store.dart';
|
||||
import 'package:immich_mobile/shared/providers/api.provider.dart';
|
||||
import 'package:immich_mobile/shared/providers/db.provider.dart';
|
||||
|
@ -26,6 +28,7 @@ final backupServiceProvider = Provider(
|
|||
(ref) => BackupService(
|
||||
ref.watch(apiServiceProvider),
|
||||
ref.watch(dbProvider),
|
||||
ref.watch(appSettingsServiceProvider),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -34,8 +37,9 @@ class BackupService {
|
|||
final ApiService _apiService;
|
||||
final Isar _db;
|
||||
final Logger _log = Logger("BackupService");
|
||||
final AppSettingsService _appSetting;
|
||||
|
||||
BackupService(this._apiService, this._db);
|
||||
BackupService(this._apiService, this._db, this._appSetting);
|
||||
|
||||
Future<List<String>?> getDeviceBackupAsset() async {
|
||||
final String deviceId = Store.get(StoreKey.deviceId);
|
||||
|
@ -209,6 +213,9 @@ class BackupService {
|
|||
Function(ErrorUploadAsset) errorCb, {
|
||||
bool sortAssets = false,
|
||||
}) async {
|
||||
final bool isIgnoreIcloudAssets =
|
||||
_appSetting.getSetting(AppSettingsEnum.ignoreIcloudAssets);
|
||||
|
||||
if (Platform.isAndroid &&
|
||||
!(await Permission.accessMediaLocation.status).isGranted) {
|
||||
// double check that permission is granted here, to guard against
|
||||
|
@ -246,6 +253,11 @@ class BackupService {
|
|||
|
||||
// Handle getting files from iCloud
|
||||
if (!isAvailableLocally && Platform.isIOS) {
|
||||
// Skip iCloud assets if the user has disabled this feature
|
||||
if (isIgnoreIcloudAssets) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setCurrentUploadAssetCb(
|
||||
CurrentUploadAsset(
|
||||
id: entity.id,
|
||||
|
|
|
@ -31,6 +31,9 @@ class BackupOptionsPage extends HookConsumerWidget {
|
|||
final settingsService = ref.watch(appSettingsServiceProvider);
|
||||
final showBackupFix = Platform.isAndroid &&
|
||||
settingsService.getSetting(AppSettingsEnum.advancedTroubleshooting);
|
||||
final ignoreIcloudAssets = useState(
|
||||
settingsService.getSetting(AppSettingsEnum.ignoreIcloudAssets),
|
||||
);
|
||||
final appRefreshDisabled =
|
||||
Platform.isIOS && settings?.appRefreshEnabled != true;
|
||||
final checkInProgress = useState(false);
|
||||
|
@ -433,7 +436,6 @@ class BackupOptionsPage extends HookConsumerWidget {
|
|||
if (!isAutoBackup)
|
||||
const Text(
|
||||
"backup_controller_page_desc_backup",
|
||||
style: TextStyle(fontSize: 14),
|
||||
).tr(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
|
@ -455,6 +457,29 @@ class BackupOptionsPage extends HookConsumerWidget {
|
|||
);
|
||||
}
|
||||
|
||||
void switchChanged(bool value) {
|
||||
settingsService.setSetting(AppSettingsEnum.ignoreIcloudAssets, value);
|
||||
ignoreIcloudAssets.value = value;
|
||||
ref.invalidate(appSettingsServiceProvider);
|
||||
}
|
||||
|
||||
buildIgnoreIcloudAssetSetting() {
|
||||
return [
|
||||
const Divider(),
|
||||
SwitchListTile.adaptive(
|
||||
title: const Text(
|
||||
"Ignore iCloud photos",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
subtitle: const Text(
|
||||
"Photos that are stored on iCloud will not be uploaded to the Immich server",
|
||||
),
|
||||
value: ignoreIcloudAssets.value,
|
||||
onChanged: switchChanged,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
|
@ -487,6 +512,7 @@ class BackupOptionsPage extends HookConsumerWidget {
|
|||
),
|
||||
if (showBackupFix) const Divider(),
|
||||
if (showBackupFix) buildCheckCorruptBackups(),
|
||||
if (Platform.isIOS) ...buildIgnoreIcloudAssetSetting(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -51,6 +51,7 @@ enum AppSettingsEnum<T> {
|
|||
mapIncludeArchived<bool>(StoreKey.mapIncludeArchived, null, false),
|
||||
mapRelativeDate<int>(StoreKey.mapRelativeDate, null, 0),
|
||||
allowSelfSignedSSLCert<bool>(StoreKey.selfSignedCert, null, false),
|
||||
ignoreIcloudAssets<bool>(StoreKey.ignoreIcloudAssets, null, false),
|
||||
;
|
||||
|
||||
const AppSettingsEnum(this.storeKey, this.hiveKey, this.defaultValue);
|
||||
|
|
|
@ -182,6 +182,7 @@ enum StoreKey<T> {
|
|||
mapRelativeDate<int>(119, type: int),
|
||||
selfSignedCert<bool>(120, type: bool),
|
||||
mapIncludeArchived<bool>(121, type: bool),
|
||||
ignoreIcloudAssets<bool>(122, type: bool),
|
||||
;
|
||||
|
||||
const StoreKey(
|
||||
|
|
Loading…
Reference in a new issue