From 44195c792a53af9731dc5e6054745892325cfa09 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 09:48:51 -0300 Subject: [PATCH 01/10] fix share drive --- .github/workflows/pr.yaml | 2 +- lib/blocs/drive_attach/drive_attach_cubit.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 5aa2358a59..52924a4b79 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -18,7 +18,7 @@ jobs: uses: ./.github/workflows/test.yml build-web: - needs: pre-build + # needs: pre-build runs-on: ubuntu-latest steps: # Checkout diff --git a/lib/blocs/drive_attach/drive_attach_cubit.dart b/lib/blocs/drive_attach/drive_attach_cubit.dart index f5b7204094..470621f3d6 100644 --- a/lib/blocs/drive_attach/drive_attach_cubit.dart +++ b/lib/blocs/drive_attach/drive_attach_cubit.dart @@ -141,10 +141,10 @@ class DriveAttachCubit extends Cubit { profileKey: _profileKey, ); - _drivesBloc.selectDrive(driveId); - emit(DriveAttachSuccess()); - unawaited(_syncBloc.startSync()); + unawaited(_syncBloc + .startSync() + .then((value) => _drivesBloc.selectDrive(driveId))); PlausibleEventTracker.trackAttachDrive( drivePrivacy: drivePrivacy, From 9c9b899ffb4654b1b5bed082d7f83bd5f7efff05 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 10:07:58 -0300 Subject: [PATCH 02/10] fix sync drive --- lib/models/daos/drive_dao/drive_dao.dart | 1 + lib/sync/domain/cubit/sync_cubit.dart | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/models/daos/drive_dao/drive_dao.dart b/lib/models/daos/drive_dao/drive_dao.dart index 2945b2c3f5..6375130b78 100644 --- a/lib/models/daos/drive_dao/drive_dao.dart +++ b/lib/models/daos/drive_dao/drive_dao.dart @@ -280,6 +280,7 @@ class DriveDao extends DatabaseAccessor with _$DriveDaoMixin { privacy: entity.privacy!, dateCreated: Value(entity.createdAt), lastUpdated: Value(entity.createdAt), + lastBlockHeight: const Value(0), ); if (entity.privacy == DrivePrivacyTag.private) { diff --git a/lib/sync/domain/cubit/sync_cubit.dart b/lib/sync/domain/cubit/sync_cubit.dart index 23608e5eb8..c08eabe1ae 100644 --- a/lib/sync/domain/cubit/sync_cubit.dart +++ b/lib/sync/domain/cubit/sync_cubit.dart @@ -206,12 +206,8 @@ class SyncCubit extends Cubit { ); } - 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, From beb833411ae1010e1ea1735d38b8ac035bf658a0 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 10:19:27 -0300 Subject: [PATCH 03/10] Update drive_attach_cubit.dart fix share drive --- lib/blocs/drive_attach/drive_attach_cubit.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/blocs/drive_attach/drive_attach_cubit.dart b/lib/blocs/drive_attach/drive_attach_cubit.dart index 470621f3d6..25370bbe2c 100644 --- a/lib/blocs/drive_attach/drive_attach_cubit.dart +++ b/lib/blocs/drive_attach/drive_attach_cubit.dart @@ -142,6 +142,15 @@ class DriveAttachCubit extends Cubit { ); emit(DriveAttachSuccess()); + + if (_syncBloc.state is SyncInProgress) { + await for (var state in _syncBloc.stream) { + if (state is SyncIdle) { + break; + } + } + } + unawaited(_syncBloc .startSync() .then((value) => _drivesBloc.selectDrive(driveId))); From ecda12b0b3c92ee2de3a92cb3199be82159f4f3e Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 10:21:09 -0300 Subject: [PATCH 04/10] Update drive_attach_cubit.dart --- lib/blocs/drive_attach/drive_attach_cubit.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/blocs/drive_attach/drive_attach_cubit.dart b/lib/blocs/drive_attach/drive_attach_cubit.dart index 25370bbe2c..d795cbc591 100644 --- a/lib/blocs/drive_attach/drive_attach_cubit.dart +++ b/lib/blocs/drive_attach/drive_attach_cubit.dart @@ -143,6 +143,7 @@ class DriveAttachCubit extends Cubit { emit(DriveAttachSuccess()); + /// Wait for the sync to finish before syncing the newly attached drive. if (_syncBloc.state is SyncInProgress) { await for (var state in _syncBloc.stream) { if (state is SyncIdle) { @@ -151,6 +152,7 @@ class DriveAttachCubit extends Cubit { } } + /// Then, select the newly attached drive. unawaited(_syncBloc .startSync() .then((value) => _drivesBloc.selectDrive(driveId))); From 3ae4774a845ca424c0a1259c4fd1f44a43fb4d8b Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 10:23:01 -0300 Subject: [PATCH 05/10] Update pr.yaml --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 52924a4b79..5aa2358a59 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -18,7 +18,7 @@ jobs: uses: ./.github/workflows/test.yml build-web: - # needs: pre-build + needs: pre-build runs-on: ubuntu-latest steps: # Checkout From 301402de33c65753876584cfd14e7b18ccbe644a Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 10:33:54 -0300 Subject: [PATCH 06/10] add new styles to attach drive modal --- lib/blocs/drive_attach/drive_attach_cubit.dart | 2 +- lib/components/drive_attach_form.dart | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/blocs/drive_attach/drive_attach_cubit.dart b/lib/blocs/drive_attach/drive_attach_cubit.dart index d795cbc591..6fd7e44d32 100644 --- a/lib/blocs/drive_attach/drive_attach_cubit.dart +++ b/lib/blocs/drive_attach/drive_attach_cubit.dart @@ -144,7 +144,7 @@ class DriveAttachCubit extends Cubit { emit(DriveAttachSuccess()); /// Wait for the sync to finish before syncing the newly attached drive. - if (_syncBloc.state is SyncInProgress) { + if (_syncBloc.state is! SyncIdle) { await for (var state in _syncBloc.stream) { if (state is SyncIdle) { break; diff --git a/lib/components/drive_attach_form.dart b/lib/components/drive_attach_form.dart index d91e12f876..65cb4b2e59 100644 --- a/lib/components/drive_attach_form.dart +++ b/lib/components/drive_attach_form.dart @@ -90,7 +90,7 @@ class _DriveAttachFormState extends State { if (state is DriveAttachInvalidDriveKey) { showArDriveDialog( context, - content: ArDriveStandardModal( + content: ArDriveStandardModalNew( title: appLocalizationsOf(context).error, description: appLocalizationsOf(context).invalidKeyFile, ), @@ -98,7 +98,7 @@ class _DriveAttachFormState extends State { } else if (state is DriveAttachDriveNotFound) { showArDriveDialog( context, - content: ArDriveStandardModal( + content: ArDriveStandardModalNew( title: appLocalizationsOf(context).error, description: appLocalizationsOf(context) .validationAttachDriveCouldNotBeFound, @@ -110,18 +110,19 @@ class _DriveAttachFormState extends State { 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().driveIdController, autofocus: true, @@ -140,7 +141,7 @@ class _DriveAttachFormState extends State { ), const SizedBox(height: 16), if (state is DriveAttachPrivate) - ArDriveTextField( + ArDriveTextFieldNew( controller: context.read().driveKeyController, autofocus: true, @@ -156,7 +157,7 @@ class _DriveAttachFormState extends State { hintText: appLocalizationsOf(context).driveKey, ), const SizedBox(height: 16), - ArDriveTextField( + ArDriveTextFieldNew( controller: context.read().driveNameController, hintText: appLocalizationsOf(context).driveName, From c2aa3a79301f1c860aae547ab3f604ca0ca07ae5 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:07:15 -0300 Subject: [PATCH 07/10] add buildwhen for build only when not syncing --- .github/workflows/pr.yaml | 2 +- lib/models/daos/drive_dao/drive_dao.dart | 1 - lib/pages/drive_detail/drive_detail_page.dart | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 5aa2358a59..52924a4b79 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -18,7 +18,7 @@ jobs: uses: ./.github/workflows/test.yml build-web: - needs: pre-build + # needs: pre-build runs-on: ubuntu-latest steps: # Checkout diff --git a/lib/models/daos/drive_dao/drive_dao.dart b/lib/models/daos/drive_dao/drive_dao.dart index 6375130b78..2945b2c3f5 100644 --- a/lib/models/daos/drive_dao/drive_dao.dart +++ b/lib/models/daos/drive_dao/drive_dao.dart @@ -280,7 +280,6 @@ class DriveDao extends DatabaseAccessor with _$DriveDaoMixin { privacy: entity.privacy!, dateCreated: Value(entity.createdAt), lastUpdated: Value(entity.createdAt), - lastBlockHeight: const Value(0), ); if (entity.privacy == DrivePrivacyTag.private) { diff --git a/lib/pages/drive_detail/drive_detail_page.dart b/lib/pages/drive_detail/drive_detail_page.dart index 61cc1db0f9..3e60fd65db 100644 --- a/lib/pages/drive_detail/drive_detail_page.dart +++ b/lib/pages/drive_detail/drive_detail_page.dart @@ -153,6 +153,9 @@ class _DriveDetailPageState extends State { } }, child: BlocBuilder( + buildWhen: (previous, current) { + return context.read().state is! SyncInProgress; + }, builder: (context, driveDetailState) { if (driveDetailState is DriveDetailLoadInProgress) { return const Center(child: CircularProgressIndicator()); From 872b44d8052283e6a90dfae43fd776054b7403f8 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:02:46 -0300 Subject: [PATCH 08/10] refactor(attach cubit) - implement logic to wait for sync on sync cubit - fix unit tests --- lib/blocs/drive_attach/drive_attach_cubit.dart | 10 ++-------- lib/sync/domain/cubit/sync_cubit.dart | 11 +++++++++++ test/blocs/drive_attach_cubit_test.dart | 5 ++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/blocs/drive_attach/drive_attach_cubit.dart b/lib/blocs/drive_attach/drive_attach_cubit.dart index 6fd7e44d32..b9912fa30c 100644 --- a/lib/blocs/drive_attach/drive_attach_cubit.dart +++ b/lib/blocs/drive_attach/drive_attach_cubit.dart @@ -144,15 +144,9 @@ class DriveAttachCubit extends Cubit { emit(DriveAttachSuccess()); /// Wait for the sync to finish before syncing the newly attached drive. - if (_syncBloc.state is! SyncIdle) { - await for (var state in _syncBloc.stream) { - if (state is SyncIdle) { - break; - } - } - } + await _syncBloc.waitCurrentSync(); - /// Then, select the newly attached drive. + /// Then, sync and select the newly attached drive. unawaited(_syncBloc .startSync() .then((value) => _drivesBloc.selectDrive(driveId))); diff --git a/lib/sync/domain/cubit/sync_cubit.dart b/lib/sync/domain/cubit/sync_cubit.dart index c08eabe1ae..f7afbf3eb0 100644 --- a/lib/sync/domain/cubit/sync_cubit.dart +++ b/lib/sync/domain/cubit/sync_cubit.dart @@ -68,6 +68,17 @@ class SyncCubit extends Cubit { restartArConnectSyncOnFocus(); } + /// Waits for the current sync to finish. + Future 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'); diff --git a/test/blocs/drive_attach_cubit_test.dart b/test/blocs/drive_attach_cubit_test.dart index 1afadbf4c3..2633bd2c6a 100644 --- a/test/blocs/drive_attach_cubit_test.dart +++ b/test/blocs/drive_attach_cubit_test.dart @@ -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, @@ -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, From 38feaf200ba0cc9082b14694a3de2e9ac8bfd494 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 15 Jul 2024 16:01:28 -0300 Subject: [PATCH 09/10] Update pr.yaml --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 52924a4b79..5aa2358a59 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -18,7 +18,7 @@ jobs: uses: ./.github/workflows/test.yml build-web: - # needs: pre-build + needs: pre-build runs-on: ubuntu-latest steps: # Checkout From 0ba0146ab3ce77cb81dc0d55e91880b0101abca9 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:07:49 -0300 Subject: [PATCH 10/10] release notes and bump version --- android/fastlane/metadata/android/en-US/changelogs/138.txt | 1 + pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 android/fastlane/metadata/android/en-US/changelogs/138.txt diff --git a/android/fastlane/metadata/android/en-US/changelogs/138.txt b/android/fastlane/metadata/android/en-US/changelogs/138.txt new file mode 100644 index 0000000000..b6057d4499 --- /dev/null +++ b/android/fastlane/metadata/android/en-US/changelogs/138.txt @@ -0,0 +1 @@ +- Fixes an issue with attaching drives on mobile Web and Android \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 6fd5ccdf74..4976c1bebd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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'