diff --git a/lib/blocs/upload/limits.dart b/lib/blocs/upload/limits.dart index cfb491ac7b..8d3bd67d04 100644 --- a/lib/blocs/upload/limits.dart +++ b/lib/blocs/upload/limits.dart @@ -7,6 +7,7 @@ final largeFileUploadSizeThreshold = const MiB(500).size; final mobilePrivateFileSizeLimit = const GiB(10).size; final publicFileSafeSizeLimit = const GiB(5).size; +final nonChromeBrowserUploadSafeLimitUsingTurbo = const MiB(500).size; int bundleSizeLimit(bool isTurbo) => isTurbo ? turboBundleSizeLimit : d2nBundleSizeLimit; diff --git a/lib/blocs/upload/upload_cubit.dart b/lib/blocs/upload/upload_cubit.dart index 1bc42db661..39c286fd13 100644 --- a/lib/blocs/upload/upload_cubit.dart +++ b/lib/blocs/upload/upload_cubit.dart @@ -421,6 +421,7 @@ class UploadCubit extends Cubit { } bool hasEmittedError = false; + bool hasEmittedWarning = false; Future startUpload({ required UploadPlan uploadPlanForAr, @@ -457,6 +458,17 @@ class UploadCubit extends Cubit { if (configService.config.useNewUploader) { if (_uploadMethod == UploadMethod.turbo) { await _verifyIfUploadContainsLargeFilesUsingTurbo(); + if (!hasEmittedWarning && kIsWeb && !await AppPlatform.isChrome()) { + emit( + UploadShowingWarning( + reason: UploadWarningReason.fileTooLargeOnNonChromeBrowser, + uploadPlanForAR: uploadPlanForAr, + uploadPlanForTurbo: uploadPlanForTurbo, + ), + ); + hasEmittedWarning = true; + return; + } } else { _containsLargeTurboUpload = false; } @@ -1006,7 +1018,11 @@ class UploadCubit extends Cubit { ); if (fileAboveWarningLimit) { - emit(UploadShowingWarning(reason: UploadWarningReason.fileTooLarge)); + emit(UploadShowingWarning( + reason: UploadWarningReason.fileTooLarge, + uploadPlanForAR: null, + uploadPlanForTurbo: null, + )); return; } diff --git a/lib/blocs/upload/upload_state.dart b/lib/blocs/upload/upload_state.dart index 6eea8916cd..72f141428f 100644 --- a/lib/blocs/upload/upload_state.dart +++ b/lib/blocs/upload/upload_state.dart @@ -242,8 +242,14 @@ class UploadWalletMismatch extends UploadState {} class UploadShowingWarning extends UploadState { final UploadWarningReason reason; + final UploadPlan? uploadPlanForAR; + final UploadPlan? uploadPlanForTurbo; - UploadShowingWarning({required this.reason}); + UploadShowingWarning({ + required this.reason, + this.uploadPlanForAR, + this.uploadPlanForTurbo, + }); @override List get props => [reason]; @@ -256,6 +262,7 @@ class CancelD2NUploadWarning extends UploadState {} enum UploadWarningReason { /// The user is attempting to upload a file that is too large. fileTooLarge, + fileTooLargeOnNonChromeBrowser, } enum UploadErrors { diff --git a/lib/components/upload_form.dart b/lib/components/upload_form.dart index fd719967fa..453c839352 100644 --- a/lib/components/upload_form.dart +++ b/lib/components/upload_form.dart @@ -755,7 +755,11 @@ class _UploadFormState extends State { Text( appLocalizationsOf(context) .weDontRecommendUploadsAboveASafeLimit( - filesize(publicFileSafeSizeLimit), + filesize( + state.reason == UploadWarningReason.fileTooLarge + ? publicFileSafeSizeLimit + : nonChromeBrowserUploadSafeLimitUsingTurbo, + ), ), style: ArDriveTypography.body.buttonNormalRegular(), ), @@ -768,8 +772,19 @@ class _UploadFormState extends State { title: appLocalizationsOf(context).cancelEmphasized, ), ModalAction( - action: () => - context.read().checkFilesAboveLimit(), + action: () { + if (state.uploadPlanForAR != null && + state.reason == + UploadWarningReason + .fileTooLargeOnNonChromeBrowser) { + return context.read().startUpload( + uploadPlanForAr: state.uploadPlanForAR!, + uploadPlanForTurbo: state.uploadPlanForTurbo, + ); + } + + return context.read().checkFilesAboveLimit(); + }, title: appLocalizationsOf(context).proceed, ), ], diff --git a/packages/ardrive_utils/lib/src/app_platform.dart b/packages/ardrive_utils/lib/src/app_platform.dart index 6cd488c64e..cc35170c05 100644 --- a/packages/ardrive_utils/lib/src/app_platform.dart +++ b/packages/ardrive_utils/lib/src/app_platform.dart @@ -50,6 +50,16 @@ class AppPlatform { final info = await (deviceInfo ?? DeviceInfoPlugin()).deviceInfo; return info is WebBrowserInfo && info.browserName == BrowserName.firefox; } + + static Future isChrome({DeviceInfoPlugin? deviceInfo}) async { + final info = await (deviceInfo ?? DeviceInfoPlugin()).deviceInfo; + return info is WebBrowserInfo && info.browserName == BrowserName.chrome; + } + + static Future isSafari({DeviceInfoPlugin? deviceInfo}) async { + final info = await (deviceInfo ?? DeviceInfoPlugin()).deviceInfo; + return info is WebBrowserInfo && info.browserName == BrowserName.safari; + } } // ignore: constant_identifier_names