Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE-6426: Release ArDrive App v2.49.2 #1790

Merged
merged 13 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/fastlane/metadata/android/en-US/changelogs/138.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixes an issue with attaching drives on mobile Web and Android
11 changes: 8 additions & 3 deletions lib/blocs/drive_attach/drive_attach_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,15 @@ class DriveAttachCubit extends Cubit<DriveAttachState> {
profileKey: _profileKey,
);

_drivesBloc.selectDrive(driveId);

emit(DriveAttachSuccess());
unawaited(_syncBloc.startSync());

/// Wait for the sync to finish before syncing the newly attached drive.
await _syncBloc.waitCurrentSync();

/// Then, sync and select the newly attached drive.
unawaited(_syncBloc
.startSync()
.then((value) => _drivesBloc.selectDrive(driveId)));

PlausibleEventTracker.trackAttachDrive(
drivePrivacy: drivePrivacy,
Expand Down
13 changes: 7 additions & 6 deletions lib/components/drive_attach_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ class _DriveAttachFormState extends State<DriveAttachForm> {
if (state is DriveAttachInvalidDriveKey) {
showArDriveDialog(
context,
content: ArDriveStandardModal(
content: ArDriveStandardModalNew(
title: appLocalizationsOf(context).error,
description: appLocalizationsOf(context).invalidKeyFile,
),
);
} else if (state is DriveAttachDriveNotFound) {
showArDriveDialog(
context,
content: ArDriveStandardModal(
content: ArDriveStandardModalNew(
title: appLocalizationsOf(context).error,
description: appLocalizationsOf(context)
.validationAttachDriveCouldNotBeFound,
Expand All @@ -110,18 +110,19 @@ class _DriveAttachFormState extends State<DriveAttachForm> {
builder: (context, state) {
if (state is DriveAttachInProgress) {
return ProgressDialog(
useNewArDriveUI: true,
title: appLocalizationsOf(context).attachingDriveEmphasized,
);
}

return ArDriveStandardModal(
return ArDriveStandardModalNew(
title: appLocalizationsOf(context).attachDriveEmphasized,
content: SizedBox(
width: kMediumDialogWidth,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ArDriveTextField(
ArDriveTextFieldNew(
controller:
context.read<DriveAttachCubit>().driveIdController,
autofocus: true,
Expand All @@ -140,7 +141,7 @@ class _DriveAttachFormState extends State<DriveAttachForm> {
),
const SizedBox(height: 16),
if (state is DriveAttachPrivate)
ArDriveTextField(
ArDriveTextFieldNew(
controller:
context.read<DriveAttachCubit>().driveKeyController,
autofocus: true,
Expand All @@ -156,7 +157,7 @@ class _DriveAttachFormState extends State<DriveAttachForm> {
hintText: appLocalizationsOf(context).driveKey,
),
const SizedBox(height: 16),
ArDriveTextField(
ArDriveTextFieldNew(
controller:
context.read<DriveAttachCubit>().driveNameController,
hintText: appLocalizationsOf(context).driveName,
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/drive_detail/drive_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class _DriveDetailPageState extends State<DriveDetailPage> {
}
},
child: BlocBuilder<DriveDetailCubit, DriveDetailState>(
buildWhen: (previous, current) {
return context.read<SyncCubit>().state is! SyncInProgress;
},
builder: (context, driveDetailState) {
if (driveDetailState is DriveDetailLoadInProgress) {
return const Center(child: CircularProgressIndicator());
Expand Down
15 changes: 11 additions & 4 deletions lib/sync/domain/cubit/sync_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ class SyncCubit extends Cubit<SyncState> {
restartArConnectSyncOnFocus();
}

/// Waits for the current sync to finish.
Future<void> waitCurrentSync() async {
if (state is! SyncIdle) {
await for (var state in stream) {
if (state is SyncIdle || state is SyncFailure) {
break;
}
}
}
}

void createSyncStream() async {
logger.d('Creating sync stream to periodically call sync automatically');

Expand Down Expand Up @@ -206,12 +217,8 @@ class SyncCubit extends Cubit<SyncState> {
);
}

final currentBlockHeight = await _syncRepository.getCurrentBlockHeight();

_promptToSnapshotBloc.add(const SyncRunning(isRunning: true));

logger.d('Current block height number $currentBlockHeight');

await for (var syncProgress in _syncRepository.syncAllDrives(
wallet: wallet,
password: password,
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.49.1
version: 2.49.2

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down
5 changes: 4 additions & 1 deletion test/blocs/drive_attach_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void main() {
arweave = MockArweaveService();
syncBloc = MockSyncBloc();
drivesBloc = MockDrivesCubit();
when(() => arweave.getLatestDriveEntityWithId(validDriveId)).thenAnswer(
when(() => arweave.getLatestDriveEntityWithId(validDriveId)).thenAnswer(
(_) => Future.value(
DriveEntity(
id: validDriveId,
Expand Down Expand Up @@ -93,6 +93,9 @@ void main() {

when(() => syncBloc.startSync()).thenAnswer((_) => Future.value(null));

when(() => syncBloc.waitCurrentSync())
.thenAnswer((_) => Future.value(null));

driveAttachCubit = DriveAttachCubit(
arweave: arweave,
driveDao: driveDao,
Expand Down
Loading