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-6456: Release ArDrive v2.49.4 #1796

Merged
merged 6 commits into from
Jul 19, 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/140.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Improves handling of a few common errors
7 changes: 7 additions & 0 deletions lib/blocs/create_manifest/create_manifest_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
}

Future<void> checkForConflicts(String name) async {
/// Prevent multiple checks from being triggered
if (state is! CreateManifestFolderLoadSuccess) {
return;
}

final parentFolder =
(state as CreateManifestFolderLoadSuccess).viewingFolder.folder;

Expand Down Expand Up @@ -180,6 +185,8 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
emit(CreateManifestPreparingManifest(parentFolder: parentFolder));

await prepareManifestTx(manifestName: name);

logger.d('No conflicts found');
}

Future<void> prepareManifestTx({
Expand Down
14 changes: 12 additions & 2 deletions lib/blocs/drive_detail/drive_detail_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:ardrive/authentication/ardrive_auth.dart';
import 'package:ardrive/blocs/blocs.dart';
import 'package:ardrive/blocs/drive_detail/utils/breadcrumb_builder.dart';
import 'package:ardrive/core/activity_tracker.dart';
import 'package:ardrive/core/arfs/repository/drive_repository.dart';
import 'package:ardrive/models/models.dart';
import 'package:ardrive/pages/pages.dart';
import 'package:ardrive/services/services.dart';
Expand Down Expand Up @@ -33,6 +34,8 @@ class DriveDetailCubit extends Cubit<DriveDetailState> {
final BreadcrumbBuilder _breadcrumbBuilder;
final SyncCubit _syncCubit;

final DriveRepository _driveRepository;

StreamSubscription? _folderSubscription;
final _defaultAvailableRowsPerPage = [25, 50, 75, 100];

Expand All @@ -57,13 +60,15 @@ class DriveDetailCubit extends Cubit<DriveDetailState> {
required ArDriveAuth auth,
required BreadcrumbBuilder breadcrumbBuilder,
required SyncCubit syncCubit,
required DriveRepository driveRepository,
}) : _profileCubit = profileCubit,
_activityTracker = activityTracker,
_driveDao = driveDao,
_auth = auth,
_configService = configService,
_breadcrumbBuilder = breadcrumbBuilder,
_syncCubit = syncCubit,
_driveRepository = driveRepository,
super(DriveDetailLoadInProgress()) {
if (driveId.isEmpty) {
return;
Expand Down Expand Up @@ -115,8 +120,8 @@ class DriveDetailCubit extends Cubit<DriveDetailState> {
await _folderSubscription?.cancel();

_folderSubscription =
Rx.combineLatest3<Drive, FolderWithContents, ProfileState, void>(
_driveDao.driveById(driveId: driveId).watchSingle(),
Rx.combineLatest3<Drive?, FolderWithContents, ProfileState, void>(
_driveRepository.watchDrive(driveId: driveId),
_driveDao.watchFolderContents(
driveId,
orderBy: contentOrderBy,
Expand All @@ -125,6 +130,11 @@ class DriveDetailCubit extends Cubit<DriveDetailState> {
),
_profileCubit.stream.startWith(ProfileCheckingAvailability()),
(drive, folderContents, _) async {
if (drive == null) {
emit(DriveDetailLoadNotFound());
return;
}

if (_activityTracker.isUploading) {
return;
}
Expand Down
9 changes: 9 additions & 0 deletions lib/core/arfs/repository/drive_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@ class DriveRepository {

return files;
}

/// Returns a stream of the drive with the given [driveId].
Stream<Drive?> watchDrive({
required String driveId,
}) {
final drive = _driveDao.driveById(driveId: driveId);

return drive.watchSingleOrNull();
}
}
5 changes: 5 additions & 0 deletions lib/pages/app_router_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_bloc.dart';
import 'package:ardrive/components/components.dart';
import 'package:ardrive/components/feedback_survey.dart';
import 'package:ardrive/core/activity_tracker.dart';
import 'package:ardrive/core/arfs/repository/drive_repository.dart';
import 'package:ardrive/core/arfs/repository/folder_repository.dart';
import 'package:ardrive/dev_tools/app_dev_tools.dart';
import 'package:ardrive/drive_explorer/multi_thumbnail_creation/multi_thumbnail_creation_modal.dart';
Expand Down Expand Up @@ -192,6 +193,10 @@ class AppRouterDelegate extends RouterDelegate<AppRoutePath>
return BlocProvider(
key: ValueKey(driveId),
create: (context) => DriveDetailCubit(
driveRepository: DriveRepository(
driveDao: context.read<DriveDao>(),
auth: context.read<ArDriveAuth>(),
),
activityTracker: context.read<ActivityTracker>(),
driveId: driveId!,
initialFolderId: driveFolderId,
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.3
version: 2.49.4

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down
37 changes: 37 additions & 0 deletions test/core/arfs/drive_repository_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,41 @@ void main() {
expect(result, isEmpty);
});
});

group('watchDrive', () {
const driveId = 'test-drive-id';
final mockDrive1 = MockDrive();

test('should return a stream of Drive when drive is found', () {
// Arrange
when(() => mockDriveDao.driveById(driveId: driveId))
.thenAnswer((_) => mockSelectableDrive);

when(() => mockSelectableDrive.watchSingleOrNull()).thenAnswer((_) {
return Stream.value(mockDrive1);
});

// Act
final driveStream = driveRepository.watchDrive(driveId: driveId);

// Assert
expectLater(driveStream, emits(mockDrive1));
});

test('should return a stream of null when drive is not found', () {
// Arrange
when(() => mockDriveDao.driveById(driveId: driveId))
.thenAnswer((_) => mockSelectableDrive);

when(() => mockSelectableDrive.watchSingleOrNull()).thenAnswer((_) {
return Stream.value(null);
});

// Act
final driveStream = driveRepository.watchDrive(driveId: driveId);

// Assert
expectLater(driveStream, emits(null));
});
});
}
Loading