Skip to content

Commit

Permalink
Merge pull request #1858 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-6745: Release ArDrive v2.54.3
  • Loading branch information
thiagocarvalhodev authored Sep 13, 2024
2 parents 9cf925d + 979c2d0 commit 8fd9f0f
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 42 deletions.
2 changes: 2 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/153.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improves ArNS name load time
- Adds a close button on the name assignment flow
5 changes: 5 additions & 0 deletions lib/arns/domain/arns_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ class _ARNSRepository implements ARNSRepository {
if (_getARNSUndernamesCompleter != null) {
return _getARNSUndernamesCompleter!.future;
}
logger.d('Loading names');
final date = DateTime.now();

_getARNSUndernamesCompleter = Completer();

Expand Down Expand Up @@ -244,6 +246,9 @@ class _ARNSRepository implements ARNSRepository {

lastUpdated = DateTime.now();

logger.d(
'Names loaded in ${DateTime.now().difference(date).inMilliseconds}ms');

_getARNSUndernamesCompleter!.complete(records);

_getARNSUndernamesCompleter = null;
Expand Down
12 changes: 5 additions & 7 deletions lib/arns/presentation/assign_name_bloc/assign_name_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ class AssignNameBloc extends Bloc<AssignNameEvent, AssignNameState> {
emit(LoadingNames());

final walletAddress = await _auth.getWalletAddress();
if (!event.updateARNSRecords) {
await _arnsRepository.waitForARNSRecordsToUpdate();
}

final names = await _arnsRepository.getAntRecordsForWallet(
walletAddress!,
update: event.updateARNSRecords,
);
final names = await _arnsRepository.getAntRecordsForWallet(walletAddress!);

if (names.isEmpty) {
emit(AssignNameEmptyState());
Expand Down Expand Up @@ -156,5 +150,9 @@ class AssignNameBloc extends Bloc<AssignNameEvent, AssignNameState> {
selectedUndername: _selectedUndername,
));
});

on<CloseAssignName>((event, emit) async {
emit(EmptySelection());
});
}
}
2 changes: 2 additions & 0 deletions lib/arns/presentation/assign_name_bloc/assign_name_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ final class LoadNames extends AssignNameEvent {
});
}

final class CloseAssignName extends AssignNameEvent {}

final class SelectName extends AssignNameEvent {
final ANTRecord name;

Expand Down
2 changes: 2 additions & 0 deletions lib/arns/presentation/assign_name_bloc/assign_name_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ final class SelectionConfirmed extends AssignNameState {
final class LoadingUndernames extends AssignNameState {}

class SelectionFailed extends AssignNameState {}

final class EmptySelection extends AssignNameState {}
26 changes: 23 additions & 3 deletions lib/arns/presentation/assign_name_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import 'package:ardrive/arns/domain/arns_repository.dart';
import 'package:ardrive/arns/presentation/assign_name_bloc/assign_name_bloc.dart';
import 'package:ardrive/authentication/ardrive_auth.dart';
import 'package:ardrive/blocs/blocs.dart';
import 'package:ardrive/blocs/drive_detail/drive_detail_cubit.dart';
import 'package:ardrive/misc/resources.dart';
import 'package:ardrive/pages/drive_detail/models/data_table_item.dart';
import 'package:ardrive/theme/theme.dart';
import 'package:ardrive/utils/logger.dart';
import 'package:ardrive/utils/open_url.dart';
import 'package:ardrive/utils/show_general_dialog.dart';
import 'package:ardrive_ui/ardrive_ui.dart';
Expand Down Expand Up @@ -50,11 +52,15 @@ class AssignArNSNameModal extends StatelessWidget {
this.updateARNSRecords = true,
this.customLoadingText,
this.customNameSelectionTitle,
this.onEmptySelection,
this.canClose = true,
});

final FileDataTableItem? file;
final DriveDetailCubit driveDetailCubit;
final Function(SelectionConfirmed)? onSelectionConfirmed;
final Function(EmptySelection)? onEmptySelection;
final bool canClose;
final bool justSelectName;
final bool updateARNSRecords;
final String? customLoadingText;
Expand All @@ -77,6 +83,8 @@ class AssignArNSNameModal extends StatelessWidget {
onSelectionConfirmed: onSelectionConfirmed,
customLoadingText: customLoadingText,
customNameSelectionTitle: customNameSelectionTitle,
onEmptySelection: onEmptySelection,
canClose: canClose,
),
);
}
Expand All @@ -91,14 +99,18 @@ class _AssignArNSNameModal extends StatefulWidget {
this.onSelectionConfirmed,
this.customLoadingText,
this.customNameSelectionTitle,
this.onEmptySelection,
this.canClose = true,
});

final DriveDetailCubit driveDetailCubit;
final bool justSelectName;
final FileDataTableItem? file;
final Function(SelectionConfirmed)? onSelectionConfirmed;
final Function(EmptySelection)? onEmptySelection;
final String? customLoadingText;
final String? customNameSelectionTitle;
final bool canClose;

@override
State<_AssignArNSNameModal> createState() => _AssignArNSNameModalState();
Expand Down Expand Up @@ -129,6 +141,10 @@ class _AssignArNSNameModalState extends State<_AssignArNSNameModal> {
if (current is SelectionConfirmed) {
widget.onSelectionConfirmed?.call(current);
}

if (current is EmptySelection) {
widget.onEmptySelection?.call(current);
}
},
buildWhen: (previous, current) {
if (current is LoadingUndernames) {
Expand All @@ -139,10 +155,14 @@ class _AssignArNSNameModalState extends State<_AssignArNSNameModal> {
},
builder: (context, state) {
return ArDriveStandardModalNew(
hasCloseButton: state is NamesLoaded ||
state is UndernamesLoaded ||
state is AssignNameEmptyState,
hasCloseButton: state is! ConfirmingSelection,
title: _getTitle(state),
close: widget.canClose
? null
: () {
logger.d('Closing assign name modal');
context.read<AssignNameBloc>().add(CloseAssignName());
},
width: (state is! NamesLoaded &&
state is! UndernamesLoaded &&
state is! LoadingNames)
Expand Down
15 changes: 3 additions & 12 deletions lib/blocs/create_manifest/create_manifest_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
// Private manifests need more consideration and are currently unavailable
emit(CreateManifestPrivacyMismatch());
}

// updates the ARNS records
_arnsRepository.getAntRecordsForWallet(
_auth.currentUser.walletAddress,
update: true,
);
}

void selectUploadMethod(
Expand Down Expand Up @@ -98,10 +92,8 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
) async {
final revisionConfirmationState = state as CreateManifestRevisionConfirm;

final arns = await _arnsRepository.getAntRecordsForWallet(
_auth.currentUser.walletAddress,
update: false,
);
final arns = await _arnsRepository
.getAntRecordsForWallet(_auth.currentUser.walletAddress);

if (arns.isNotEmpty) {
emit(
Expand Down Expand Up @@ -181,8 +173,7 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {

Future<void> checkNameConflicts(String name) async {
final arns = await _arnsRepository.getAntRecordsForWallet(
_auth.currentUser.walletAddress,
update: false,
_auth.currentUser.walletAddress
);

final parentFolder =
Expand Down
31 changes: 27 additions & 4 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,32 @@ class UploadCubit extends Cubit<UploadState> {
}
}

void cancelArnsNameSelection() {
if (state is UploadReady) {
logger.d('Cancelling ARNS name selection');

final readyState = state as UploadReady;

showArnsNameSelectionCheckBoxValue = false;

emit(readyState.copyWith(
showArnsNameSelection: false,
loadingArNSNames: false,
loadingArNSNamesError: false,
showArnsCheckbox: true,
));
} else if (state is UploadReviewWithLicense) {
final reviewWithLicense = state as UploadReviewWithLicense;
final readyState = reviewWithLicense.readyState.copyWith(
showArnsNameSelection: false,
loadingArNSNames: false,
loadingArNSNamesError: false,
showArnsCheckbox: true,
);
emit(readyState);
}
}

void reviewBack() {
if (state is UploadReviewWithLicense) {
final reviewWithLicense = state as UploadReviewWithLicense;
Expand Down Expand Up @@ -317,10 +343,7 @@ class UploadCubit extends Cubit<UploadState> {
Future<void> startUploadPreparation({
bool isRetryingToPayWithTurbo = false,
}) async {
_arnsRepository.getAntRecordsForWallet(
_auth.currentUser.walletAddress,
update: true,
);
_arnsRepository.getAntRecordsForWallet(_auth.currentUser.walletAddress);

files.removeWhere((file) => filesNamesToExclude.contains(file.ioFile.name));
_targetDrive = await _driveDao.driveById(driveId: driveId).getSingle();
Expand Down
1 change: 1 addition & 0 deletions lib/blocs/upload/upload_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class UploadReady extends UploadState {
loadingArNSNamesError,
loadingArNSNames,
showArnsCheckbox,

];

@override
Expand Down
11 changes: 11 additions & 0 deletions lib/components/upload_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ class _UploadFormState extends State<UploadForm> {
),
);
} else if (state is UploadReady) {
logger.d('UploadReady state: ${state.showArnsNameSelection}');

if (state.showArnsNameSelection) {
return AssignArNSNameModal(
driveDetailCubit: widget.driveDetailCubit,
Expand All @@ -529,6 +531,11 @@ class _UploadFormState extends State<UploadForm> {
context.read<UploadCubit>().selectUndername(
name.selectedName, name.selectedUndername);
},
canClose: false,
onEmptySelection: (emptySelection) {
logger.d('Cancelling ARNS name selection');
context.read<UploadCubit>().cancelArnsNameSelection();
},
);
}

Expand Down Expand Up @@ -777,6 +784,10 @@ class _UploadFormState extends State<UploadForm> {
undername: name.selectedUndername,
);
},
canClose: false,
onEmptySelection: (emptySelection) {
context.read<UploadCubit>().cancelArnsNameSelection();
},
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void main() async {
await _startApp();
}, (error, stackTrace) async {
logger.e('Error caught.', error, stackTrace);
logger.d('Error: ${error.toString()}');
});
}

Expand Down
10 changes: 9 additions & 1 deletion packages/ardrive_ui/lib/src/components/modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ class ArDriveStandardModalNew extends StatelessWidget {
this.actions,
this.width,
this.hasCloseButton = false,
this.close,
});

final String? title;
Expand All @@ -692,6 +693,7 @@ class ArDriveStandardModalNew extends StatelessWidget {
final Widget? content;
final double? width;
final bool hasCloseButton;
final Function()? close;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -732,7 +734,13 @@ class ArDriveStandardModalNew extends StatelessWidget {
if (hasCloseButton)
ArDriveClickArea(
child: GestureDetector(
onTap: () => Navigator.pop(context),
onTap: () {
if (close != null) {
close?.call();
} else {
Navigator.pop(context);
}
},
child: const Align(
alignment: Alignment.centerRight,
child: ArDriveIcon(
Expand Down
2 changes: 1 addition & 1 deletion packages/ario_sdk/web/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129805,7 +129805,7 @@ async function $6efb768676258e07$var$getProcesses(address) {
});
arnsEmitter.fetchProcessesOwnedByWallet({
address: address,
pageSize: 100
pageSize: 10000
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ario_sdk/web/dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ario_sdk/web/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async function getProcesses(address) {

arnsEmitter.fetchProcessesOwnedByWallet({
address: address,
pageSize: 100
pageSize: 10000
});
});
}
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.54.2
version: 2.54.3

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down
22 changes: 12 additions & 10 deletions test/arns/presentation/assign_name_bloc/assign_name_bloc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void main() {

when(() => mockAuth.getWalletAddress())
.thenAnswer((_) async => walletAddress);
when(() => mockArnsRepository.getAntRecordsForWallet(walletAddress,
update: true)).thenAnswer((_) async => antRecords);
when(() => mockArnsRepository.getAntRecordsForWallet(walletAddress))
.thenAnswer((_) async => antRecords);

// Act
assignNameBloc.add(const LoadNames());
Expand All @@ -74,8 +74,9 @@ void main() {
);

verify(() => mockAuth.getWalletAddress()).called(1);
verify(() => mockArnsRepository.getAntRecordsForWallet(walletAddress,
update: true)).called(1);
verify(() => mockArnsRepository.getAntRecordsForWallet(
walletAddress,
)).called(1);
});

test(
Expand All @@ -87,8 +88,8 @@ void main() {

when(() => mockAuth.getWalletAddress())
.thenAnswer((_) async => walletAddress);
when(() => mockArnsRepository.getAntRecordsForWallet(walletAddress,
update: true)).thenAnswer((_) async => antRecords);
when(() => mockArnsRepository.getAntRecordsForWallet(walletAddress))
.thenAnswer((_) async => antRecords);

// Act
assignNameBloc.add(const LoadNames());
Expand All @@ -103,8 +104,9 @@ void main() {
);

verify(() => mockAuth.getWalletAddress()).called(1);
verify(() => mockArnsRepository.getAntRecordsForWallet(walletAddress,
update: true)).called(1);
verify(() => mockArnsRepository.getAntRecordsForWallet(
walletAddress,
)).called(1);
});
});

Expand Down Expand Up @@ -294,8 +296,8 @@ void main() {

when(() => mockAuth.getWalletAddress())
.thenAnswer((_) async => walletAddress);
when(() => mockArnsRepository.getAntRecordsForWallet(walletAddress,
update: true)).thenAnswer((_) async => antRecords);
when(() => mockArnsRepository.getAntRecordsForWallet(walletAddress))
.thenAnswer((_) async => antRecords);
when(() => mockArnsRepository.setUndernamesToFile(
undername: any(named: 'undername'),
fileId: any(named: 'fileId'),
Expand Down
Loading

0 comments on commit 8fd9f0f

Please sign in to comment.