Skip to content

Commit

Permalink
Merge pull request #1957 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-7410: Release ArDrive v2.62.0
  • Loading branch information
thiagocarvalhodev authored Jan 10, 2025
2 parents a6c83c8 + a9a7340 commit 16b087f
Show file tree
Hide file tree
Showing 39 changed files with 1,545 additions and 296 deletions.
5 changes: 5 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/171.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Introduced fallback transaction ID support for handling unresolved resource paths in manifests
- Enhanced file upload efficiency by directly uploading small files and using chunked uploads only for files larger than 5MiB
- Updated wallet switch dialog to use the new modal components
- Fixed issue preventing users from renaming a drive to a name already in use
- Fixed an issue preventing downloads for some users in Brave browser
17 changes: 13 additions & 4 deletions lib/app_shell.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:ardrive/authentication/ardrive_auth.dart';
import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart';
import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_event.dart';
import 'package:ardrive/components/profile_card.dart';
Expand Down Expand Up @@ -46,14 +47,22 @@ class AppShellState extends State<AppShell> {
@override
void initState() {
onArConnectWalletSwitch(() {
logger.d('Wallet switch detected');
context.read<ProfileCubit>().isCurrentProfileArConnect().then(
(isCurrentProfileArConnect) {
if (_showWalletSwitchDialog) {
if (isCurrentProfileArConnect) {
showDialog(
context: context,
builder: (context) => const WalletSwitchDialog(),
);
context.read<ArDriveAuth>().isUserLoggedIn().then((isLoggedIn) {
context.read<ProfileCubit>().logoutIfWalletMismatch();
if (isLoggedIn) {
logger.d('Wallet switch detected while logged in'
' to ArConnect. Showing wallet switch dialog.');
showArDriveDialog(
context,
content: const WalletSwitchDialog(),
);
}
});
} else {
logger.d('Wallet switch detected while not logged in'
' to ArConnect. Ignoring.');
Expand Down
11 changes: 6 additions & 5 deletions lib/authentication/ardrive_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,17 @@ class ArDriveAuthImpl implements ArDriveAuth {
logger.d('Logging out user');

try {
await _userRepository.deleteUser();

if (_currentUser != null) {
await _disconnectFromArConnect();
(await _metadataCache).clear();
await _secureKeyValueStore.remove('password');
await _secureKeyValueStore.remove('biometricEnabled');
currentUser = null;
await _disconnectFromArConnect();
}

await _userRepository.deleteUser();

await _databaseHelpers.deleteAllTables();
(await _metadataCache).clear();
currentUser = null;
_userStreamController.add(null);
} catch (e, stacktrace) {
logger.e('Failed to logout user', e, stacktrace);
Expand Down
1 change: 1 addition & 0 deletions lib/authentication/login/blocs/login_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
}

onArConnectWalletSwitch(() async {
logger.d('Wallet switch detected on LoginBloc');
final isUserLoggedIng = await _arDriveAuth.isUserLoggedIn();
if (isUserLoggedIng && !_isArConnectWallet()) {
logger.d(
Expand Down
34 changes: 34 additions & 0 deletions lib/blocs/create_manifest/create_manifest_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
canUpload: canUpload,
freeUpload: info.isFreeThanksToTurbo,
assignedName: (state as CreateManifestUploadReview).assignedName,
fallbackTxId: (state as CreateManifestUploadReview).fallbackTxId,
),
);
}
Expand Down Expand Up @@ -139,6 +140,7 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
CreateManifestFolderLoadSuccess(
viewingRootFolder: f.folder.parentFolderId == null,
viewingFolder: f,
enableManifestCreationButton: _getEnableManifestCreationButton(),
),
),
);
Expand Down Expand Up @@ -249,6 +251,7 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
manifestName: manifestName,
rootFolderNode: rootFolderNode,
driveId: _drive.id,
fallbackTxId: _getFallbackTxId(),
);

ARNSUndername? undername = getSelectedUndername();
Expand All @@ -264,6 +267,7 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
existingManifestFileId: existingManifestFileId,
assignedName:
undername != null ? getLiteralARNSRecordName(undername) : null,
fallbackTxId: _getFallbackTxId(),
),
);
} catch (e) {
Expand Down Expand Up @@ -303,6 +307,7 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
createManifestUploadReview.existingManifestFileId,
uploadType: uploadType,
wallet: _auth.currentUser.wallet,
fallbackTxId: _getFallbackTxId(),
),
processId: _selectedAntRecord?.processId,
undername: getSelectedUndername(),
Expand Down Expand Up @@ -367,6 +372,35 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
prepareManifestTx(manifestName: manifestName);
}

TxID? _fallbackTxId;

void setFallbackTxId(TxID txId, {bool emitState = true}) {
_fallbackTxId = txId;

if (emitState) {
emit(
(state as CreateManifestFolderLoadSuccess).copyWith(
fallbackTxId: _getFallbackTxId(),
enableManifestCreationButton: _getEnableManifestCreationButton(),
),
);
}
}

TxID? _getFallbackTxId() {
if (_fallbackTxId == null || _fallbackTxId!.isEmpty) {
return null;
}

return _fallbackTxId;
}

bool _getEnableManifestCreationButton() {
return _getFallbackTxId() == null ||
_getFallbackTxId()!.isEmpty ||
isValidArweaveTxId(_getFallbackTxId()!);
}

@override
Future<void> close() async {
await _selectedFolderSubscription?.cancel();
Expand Down
29 changes: 28 additions & 1 deletion lib/blocs/create_manifest/create_manifest_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,36 @@ class CreateManifestInitial extends CreateManifestState {}
class CreateManifestFolderLoadSuccess extends CreateManifestState {
final bool viewingRootFolder;
final FolderWithContents viewingFolder;
final bool enableManifestCreationButton;
final String? fallbackTxId;

CreateManifestFolderLoadSuccess({
required this.viewingRootFolder,
required this.viewingFolder,
required this.enableManifestCreationButton,
this.fallbackTxId,
});

CreateManifestFolderLoadSuccess copyWith({
bool? enableManifestCreationButton,
String? fallbackTxId,
}) {
return CreateManifestFolderLoadSuccess(
viewingRootFolder: viewingRootFolder,
viewingFolder: viewingFolder,
enableManifestCreationButton:
enableManifestCreationButton ?? this.enableManifestCreationButton,
fallbackTxId: fallbackTxId ?? this.fallbackTxId,
);
}

@override
List<Object> get props => [viewingRootFolder, viewingFolder];
List<Object?> get props => [
viewingRootFolder,
viewingFolder,
enableManifestCreationButton,
fallbackTxId,
];
}

/// User has selected a folder and we are checking for name conflicts
Expand Down Expand Up @@ -109,6 +131,7 @@ class CreateManifestUploadReview extends CreateManifestState {
final String? existingManifestFileId;
final bool canUpload;
final String? assignedName;
final String? fallbackTxId;

CreateManifestUploadReview({
required this.manifestSize,
Expand All @@ -122,6 +145,7 @@ class CreateManifestUploadReview extends CreateManifestState {
this.existingManifestFileId,
this.canUpload = false,
this.assignedName,
this.fallbackTxId,
});

@override
Expand All @@ -136,6 +160,7 @@ class CreateManifestUploadReview extends CreateManifestState {
parentFolder,
existingManifestFileId,
assignedName,
fallbackTxId,
];

CreateManifestUploadReview copyWith({
Expand All @@ -150,6 +175,7 @@ class CreateManifestUploadReview extends CreateManifestState {
String? existingManifestFileId,
bool? canUpload,
String? assignedName,
String? fallbackTxId,
}) {
return CreateManifestUploadReview(
manifestSize: manifestSize ?? this.manifestSize,
Expand All @@ -165,6 +191,7 @@ class CreateManifestUploadReview extends CreateManifestState {
existingManifestFileId ?? this.existingManifestFileId,
canUpload: canUpload ?? this.canUpload,
assignedName: assignedName ?? this.assignedName,
fallbackTxId: fallbackTxId ?? this.fallbackTxId,
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/blocs/drive_rename/drive_rename_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class DriveRenameCubit extends Cubit<DriveRenameState> {

Future<void> submit({
required String newName,
bool proceedIfHasConflicts = false,
}) async {
try {
final profile = _profileCubit.state as ProfileLoggedIn;
Expand All @@ -47,7 +48,7 @@ class DriveRenameCubit extends Cubit<DriveRenameState> {
return;
}

if (await _fileWithSameNameExistis(newName)) {
if (await _fileWithSameNameExistis(newName) && !proceedIfHasConflicts) {
final previousState = state;
emit(DriveNameAlreadyExists(newName));
emit(previousState);
Expand Down
15 changes: 10 additions & 5 deletions lib/blocs/file_download/personal_file_download_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ class ProfileFileDownloadCubit extends FileDownloadCubit {
super(FileDownloadStarting());

Future<void> verifyUploadLimitationsAndDownload(SecretKey? cipherKey) async {
if (await AppPlatform.isSafari()) {
if (_file.size > publicDownloadSafariSizeLimit) {
emit(const FileDownloadFailure(
FileDownloadFailureReason.browserDoesNotSupportLargeDownloads));
return;
try {
if (await AppPlatform.isSafari()) {
if (_file.size > publicDownloadSafariSizeLimit) {
emit(const FileDownloadFailure(
FileDownloadFailureReason.browserDoesNotSupportLargeDownloads));
return;
}
}
} catch (e) {
logger.d(
'Error verifying upload limitations and downloading file... proceeding with download');
}

download(cipherKey);
Expand Down
14 changes: 10 additions & 4 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class UploadCubit extends Cubit<UploadState> {
)
.getSingle();

/// If the manifest has a fallback tx id, we need to reuse it
await _createManifestCubit.prepareManifestTx(
manifestName: manifestFileEntry.name,
folderId: manifestFileEntry.parentFolderId,
Expand Down Expand Up @@ -223,20 +224,25 @@ class UploadCubit extends Cubit<UploadState> {
)
.getSingle();

if (manifestFileEntry.fallbackTxId != null) {
_createManifestCubit.setFallbackTxId(
manifestFileEntry.fallbackTxId!,
emitState: false,
);
}

await _createManifestCubit.prepareManifestTx(
manifestName: manifestFileEntry.name,
folderId: manifestFileEntry.parentFolderId,
existingManifestFileId: manifestModels[i].existingManifestFileId,
);

emit(UploadingManifests(
manifestFiles: manifestModels,
manifestFiles: manifestModels,
completedCount: completedCount,
));

await _createManifestCubit.uploadManifest(
method: _manifestUploadMethod,
);
await _createManifestCubit.uploadManifest(method: _manifestUploadMethod);

final manifestFile = await _driveDao
.fileById(
Expand Down
72 changes: 72 additions & 0 deletions lib/components/create_manifest_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,30 @@ class _CreateManifestFormState extends State<CreateManifestForm> {
filesize(state.manifestSize),
style: textStyle,
),
const SizedBox(height: 8),
if (state.fallbackTxId != null) ...[
RichText(
text: TextSpan(
style: textStyle,
children: [
TextSpan(
text: 'Fallback TxId\n',
style: typography.paragraphLarge(
color: colorTokens.textHigh,
fontWeight: ArFontWeight.bold,
),
),
TextSpan(
text: state.fallbackTxId,
style: typography.paragraphSmall(
color: colorTokens.textMid,
fontWeight: ArFontWeight.semiBold,
),
),
],
),
),
],
],
),
),
Expand Down Expand Up @@ -874,6 +898,53 @@ class _CreateManifestFormState extends State<CreateManifestForm> {
),
),
const Divider(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ArDriveClickArea(
child: ArDriveTooltip(
message:
'The fallback specifies a default content to show if the requested path cannot be found.\nThis is typically used for handling missing pages or errors, like a \'404 Not Found\' page.',
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Fallback TxId',
style: typography.paragraphNormal(
color: colorTokens.textLow,
fontWeight: ArFontWeight.semiBold,
),
),
const SizedBox(width: 8),
ArDriveIcons.info(
size: 16,
color: colorTokens.iconMid,
),
],
),
),
),
),
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ArDriveTextFieldNew(
hintText: 'TxId',
onChanged: (value) {
cubit.setFallbackTxId(value);
},
validator: (value) {
if (value == null || value.isEmpty) {
return null;
}

return isValidArweaveTxId(value) ? null : 'Invalid TxId';
},
),
),
const Divider(
height: 24,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ArDriveCard(
Expand Down Expand Up @@ -901,6 +972,7 @@ class _CreateManifestFormState extends State<CreateManifestForm> {
),
),
action: ModalAction(
isEnable: state.enableManifestCreationButton,
action: () => cubit.checkForConflicts(_manifestNameController.text),
title: appLocalizationsOf(context).createHereEmphasized,
),
Expand Down
Loading

0 comments on commit 16b087f

Please sign in to comment.