diff --git a/android/fastlane/metadata/android/en-US/changelogs/144.txt b/android/fastlane/metadata/android/en-US/changelogs/144.txt new file mode 100644 index 0000000000..ee79ea9f7e --- /dev/null +++ b/android/fastlane/metadata/android/en-US/changelogs/144.txt @@ -0,0 +1,2 @@ +- Show thumbnail checkbox only when images are present in uploads. +- Fixed issue with saving advanced settings. diff --git a/lib/blocs/upload/upload_cubit.dart b/lib/blocs/upload/upload_cubit.dart index af66faadbd..3dc3cdf56a 100644 --- a/lib/blocs/upload/upload_cubit.dart +++ b/lib/blocs/upload/upload_cubit.dart @@ -16,6 +16,7 @@ import 'package:ardrive/services/config/config.dart'; import 'package:ardrive/services/config/config_service.dart'; import 'package:ardrive/services/license/license.dart'; import 'package:ardrive/turbo/services/upload_service.dart'; +import 'package:ardrive/utils/constants.dart'; import 'package:ardrive/utils/logger.dart'; import 'package:ardrive/utils/plausible_event_tracker/plausible_custom_event_properties.dart'; import 'package:ardrive/utils/plausible_event_tracker/plausible_event_tracker.dart'; @@ -430,6 +431,17 @@ class UploadCubit extends Cubit { return; } + final containsSupportedImageTypeForThumbnailGeneration = files.any( + (element) => supportedImageTypesInFilePreview.contains( + element.ioFile.contentType, + ), + ); + + // if there are no files that can be used to generate a thumbnail, we disable the option + if (!containsSupportedImageTypeForThumbnailGeneration) { + _uploadThumbnail = false; + } + emit( UploadReadyToPrepare( params: UploadParams( @@ -439,6 +451,8 @@ class UploadCubit extends Cubit { targetDrive: _targetDrive, conflictingFiles: conflictingFiles, foldersByPath: foldersByPath, + containsSupportedImageTypeForThumbnailGeneration: + containsSupportedImageTypeForThumbnailGeneration, ), isArConnect: await _profileCubit.isCurrentProfileArConnect(), ), diff --git a/lib/components/create_manifest_form.dart b/lib/components/create_manifest_form.dart index 83ac96abd3..029e77f0e7 100644 --- a/lib/components/create_manifest_form.dart +++ b/lib/components/create_manifest_form.dart @@ -478,6 +478,9 @@ class _CreateManifestFormState extends State { targetDrive: state.drive, targetFolder: state.parentFolder, user: context.read().currentUser, + // Theres no thumbnail generation for manifests + containsSupportedImageTypeForThumbnailGeneration: + false, ), ), ), diff --git a/lib/components/upload_form.dart b/lib/components/upload_form.dart index ff2a67d7ba..0a35d71c82 100644 --- a/lib/components/upload_form.dart +++ b/lib/components/upload_form.dart @@ -480,36 +480,38 @@ class _UploadFormState extends State { }, ), ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: Row( - children: [ - ArDriveCheckBox( - title: 'Upload with thumbnails', - checked: context - .read() - .config - .uploadThumbnails, - titleStyle: typography.paragraphLarge( - fontWeight: ArFontWeight.semiBold, - ), - onChange: (value) { - context - .read() - .changeUploadThumbnailOption(value); - }, - ), - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: ArDriveIconButton( - icon: ArDriveIcons.info(), - tooltip: - 'Uploading with thumbnails is free, but may make your upload take longer.\nYou can always attach a thumbnail later.', + if (state.params + .containsSupportedImageTypeForThumbnailGeneration) + Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: Row( + children: [ + ArDriveCheckBox( + title: 'Upload with thumbnails', + checked: context + .read() + .config + .uploadThumbnails, + titleStyle: typography.paragraphLarge( + fontWeight: ArFontWeight.semiBold, + ), + onChange: (value) { + context + .read() + .changeUploadThumbnailOption(value); + }, ), - ) - ], + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: ArDriveIconButton( + icon: ArDriveIcons.info(), + tooltip: + 'Uploading with thumbnails is free, but may make your upload take longer.\nYou can always attach a thumbnail later.', + ), + ) + ], + ), ), - ), SizedBox( child: ReactiveForm( formGroup: diff --git a/lib/core/upload/uploader.dart b/lib/core/upload/uploader.dart index 93ce7ed104..680041a947 100644 --- a/lib/core/upload/uploader.dart +++ b/lib/core/upload/uploader.dart @@ -625,6 +625,7 @@ class UploadParams { final Drive targetDrive; final Map conflictingFiles; final Map foldersByPath; + final bool containsSupportedImageTypeForThumbnailGeneration; UploadParams({ required this.user, @@ -633,5 +634,6 @@ class UploadParams { required this.targetDrive, required this.conflictingFiles, required this.foldersByPath, + required this.containsSupportedImageTypeForThumbnailGeneration, }); } diff --git a/lib/services/config/config_fetcher.dart b/lib/services/config/config_fetcher.dart index a3e072ae0c..6b2b7319b2 100644 --- a/lib/services/config/config_fetcher.dart +++ b/lib/services/config/config_fetcher.dart @@ -13,11 +13,7 @@ class ConfigFetcher { ConfigFetcher({required this.localStore}); Future fetchConfig(Flavor flavor) async { - if (flavor == Flavor.production) { - return loadFromEnv('prod'); - } else { - return loadFromDevToolsPrefs(flavor); - } + return loadFromLocalSettings(flavor); } @visibleForTesting @@ -34,7 +30,7 @@ class ConfigFetcher { } @visibleForTesting - Future loadFromDevToolsPrefs(Flavor flavor) async { + Future loadFromLocalSettings(Flavor flavor) async { try { final config = localStore.getString('config'); diff --git a/pubspec.yaml b/pubspec.yaml index bc02c2526c..2f58a16707 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Secure, permanent storage publish_to: 'none' -version: 2.50.0 +version: 2.50.1 environment: sdk: '>=3.2.0 <4.0.0' diff --git a/test/blocs/upload_cubit_test.dart b/test/blocs/upload_cubit_test.dart index 26bf56a601..f1a0deea0e 100644 --- a/test/blocs/upload_cubit_test.dart +++ b/test/blocs/upload_cubit_test.dart @@ -135,6 +135,7 @@ void main() { targetDrive: getFakeDrive(), conflictingFiles: {}, foldersByPath: {}, + containsSupportedImageTypeForThumbnailGeneration: false, )); tWalletAddress = await tWallet.getAddress(); diff --git a/test/core/upload/uploader_test.dart b/test/core/upload/uploader_test.dart index 739223fa42..1df758737f 100644 --- a/test/core/upload/uploader_test.dart +++ b/test/core/upload/uploader_test.dart @@ -780,6 +780,7 @@ void main() { targetDrive: getFakeDrive(), conflictingFiles: {}, foldersByPath: {}, + containsSupportedImageTypeForThumbnailGeneration: false, )); registerFallbackValue(getFakeFolder()); registerFallbackValue(getFakeDrive()); @@ -796,6 +797,7 @@ void main() { targetDrive: getFakeDrive(), conflictingFiles: {}, foldersByPath: {}, + containsSupportedImageTypeForThumbnailGeneration: false, ); uploadPreparer = UploadPreparer(uploadPlanUtils: uploadPlanUtils); }); @@ -896,6 +898,7 @@ void main() { targetDrive: getFakeDrive(), conflictingFiles: {}, foldersByPath: {}, + containsSupportedImageTypeForThumbnailGeneration: false, )); }); diff --git a/test/services/config/config_fetcher_test.dart b/test/services/config/config_fetcher_test.dart index 87071c4c1f..fb2aaf6fbd 100644 --- a/test/services/config/config_fetcher_test.dart +++ b/test/services/config/config_fetcher_test.dart @@ -33,20 +33,6 @@ void main() { )..toJson()); group('fetchConfig', () { - test('returns the production config when flavor is production', () async { - when(() => localStore.getString('arweaveGatewayUrl')) - .thenReturn('gatewayUrl'); - when(() => localStore.getBool('enableQuickSyncAuthoring')) - .thenReturn(true); - when(() => assetBundle.loadString('assets/config/prod.json')) - .thenAnswer((_) async => '{}'); - - final result = await configFetcher.fetchConfig(Flavor.production); - - expect(result, isInstanceOf()); - expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl')); - }); - test('returns the dev config when flavor is dev', () async { when(() => localStore.getString('config')).thenReturn(configStringDev); @@ -89,7 +75,7 @@ void main() { when(() => localStore.getString('config')).thenReturn(configStringDev); final result = - await configFetcher.loadFromDevToolsPrefs(Flavor.development); + await configFetcher.loadFromLocalSettings(Flavor.development); expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('devGatewayUrl')); @@ -108,7 +94,7 @@ void main() { .thenAnswer((i) => Future.value(true)); final result = - await configFetcher.loadFromDevToolsPrefs(Flavor.development); + await configFetcher.loadFromLocalSettings(Flavor.development); expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl')); @@ -129,7 +115,7 @@ void main() { .thenAnswer((i) => Future.value(true)); final result = - await configFetcher.loadFromDevToolsPrefs(Flavor.development); + await configFetcher.loadFromLocalSettings(Flavor.development); expect(result, isInstanceOf()); expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl'));