Skip to content

Commit

Permalink
Merge pull request #1819 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-6561: Release ArDrive v2.50.1
  • Loading branch information
thiagocarvalhodev authored Aug 9, 2024
2 parents 29cd59c + f592959 commit ebb6663
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 52 deletions.
2 changes: 2 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/144.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Show thumbnail checkbox only when images are present in uploads.
- Fixed issue with saving advanced settings.
14 changes: 14 additions & 0 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -430,6 +431,17 @@ class UploadCubit extends Cubit<UploadState> {
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(
Expand All @@ -439,6 +451,8 @@ class UploadCubit extends Cubit<UploadState> {
targetDrive: _targetDrive,
conflictingFiles: conflictingFiles,
foldersByPath: foldersByPath,
containsSupportedImageTypeForThumbnailGeneration:
containsSupportedImageTypeForThumbnailGeneration,
),
isArConnect: await _profileCubit.isCurrentProfileArConnect(),
),
Expand Down
3 changes: 3 additions & 0 deletions lib/components/create_manifest_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ class _CreateManifestFormState extends State<CreateManifestForm> {
targetDrive: state.drive,
targetFolder: state.parentFolder,
user: context.read<ArDriveAuth>().currentUser,
// Theres no thumbnail generation for manifests
containsSupportedImageTypeForThumbnailGeneration:
false,
),
),
),
Expand Down
58 changes: 30 additions & 28 deletions lib/components/upload_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -480,36 +480,38 @@ class _UploadFormState extends State<UploadForm> {
},
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Row(
children: [
ArDriveCheckBox(
title: 'Upload with thumbnails',
checked: context
.read<ConfigService>()
.config
.uploadThumbnails,
titleStyle: typography.paragraphLarge(
fontWeight: ArFontWeight.semiBold,
),
onChange: (value) {
context
.read<UploadCubit>()
.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<ConfigService>()
.config
.uploadThumbnails,
titleStyle: typography.paragraphLarge(
fontWeight: ArFontWeight.semiBold,
),
onChange: (value) {
context
.read<UploadCubit>()
.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:
Expand Down
2 changes: 2 additions & 0 deletions lib/core/upload/uploader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ class UploadParams {
final Drive targetDrive;
final Map<String, String> conflictingFiles;
final Map<String, WebFolder> foldersByPath;
final bool containsSupportedImageTypeForThumbnailGeneration;

UploadParams({
required this.user,
Expand All @@ -633,5 +634,6 @@ class UploadParams {
required this.targetDrive,
required this.conflictingFiles,
required this.foldersByPath,
required this.containsSupportedImageTypeForThumbnailGeneration,
});
}
8 changes: 2 additions & 6 deletions lib/services/config/config_fetcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ class ConfigFetcher {
ConfigFetcher({required this.localStore});

Future<AppConfig> fetchConfig(Flavor flavor) async {
if (flavor == Flavor.production) {
return loadFromEnv('prod');
} else {
return loadFromDevToolsPrefs(flavor);
}
return loadFromLocalSettings(flavor);
}

@visibleForTesting
Expand All @@ -34,7 +30,7 @@ class ConfigFetcher {
}

@visibleForTesting
Future<AppConfig> loadFromDevToolsPrefs(Flavor flavor) async {
Future<AppConfig> loadFromLocalSettings(Flavor flavor) async {
try {
final config = localStore.getString('config');

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions test/blocs/upload_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void main() {
targetDrive: getFakeDrive(),
conflictingFiles: {},
foldersByPath: {},
containsSupportedImageTypeForThumbnailGeneration: false,
));

tWalletAddress = await tWallet.getAddress();
Expand Down
3 changes: 3 additions & 0 deletions test/core/upload/uploader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ void main() {
targetDrive: getFakeDrive(),
conflictingFiles: {},
foldersByPath: {},
containsSupportedImageTypeForThumbnailGeneration: false,
));
registerFallbackValue(getFakeFolder());
registerFallbackValue(getFakeDrive());
Expand All @@ -796,6 +797,7 @@ void main() {
targetDrive: getFakeDrive(),
conflictingFiles: {},
foldersByPath: {},
containsSupportedImageTypeForThumbnailGeneration: false,
);
uploadPreparer = UploadPreparer(uploadPlanUtils: uploadPlanUtils);
});
Expand Down Expand Up @@ -896,6 +898,7 @@ void main() {
targetDrive: getFakeDrive(),
conflictingFiles: {},
foldersByPath: {},
containsSupportedImageTypeForThumbnailGeneration: false,
));
});

Expand Down
20 changes: 3 additions & 17 deletions test/services/config/config_fetcher_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppConfig>());
expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl'));
});

test('returns the dev config when flavor is dev', () async {
when(() => localStore.getString('config')).thenReturn(configStringDev);

Expand Down Expand Up @@ -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<AppConfig>());
expect(result.defaultArweaveGatewayUrl, equals('devGatewayUrl'));
Expand All @@ -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<AppConfig>());
expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl'));
Expand All @@ -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<AppConfig>());
expect(result.defaultArweaveGatewayUrl, equals('gatewayUrl'));
Expand Down

0 comments on commit ebb6663

Please sign in to comment.