Skip to content

Commit

Permalink
Merge pull request #1581 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-5492: Release App v3.21.0
  • Loading branch information
thiagocarvalhodev authored Jan 29, 2024
2 parents c24e958 + cd76603 commit b01248c
Show file tree
Hide file tree
Showing 49 changed files with 1,536 additions and 554 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
RELEASE_NOTES: ${{ github.event.pull_request.title }} - ${{ github.sha }}

jobs:
pre-build:
uses: ./.github/workflows/test.yml
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
scr setup
flutter config --enable-web
flutter build web --dart-define=environment=development --release --pwa-strategy=none --no-web-resources-cdn
flutter build web --dart-define=environment=development --release --pwa-strategy=none --no-web-resources-cdn --source-maps
# JS files cache invalidation
- name: main.dart.js and service worker cache invalidation
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
env:
BUILD_NUMBER: ${{ github.run_number }}
RELEASE_NOTES: 'Production'
SENTRY_DSN: ${{secrets.SENTRY_DSN}}
SENTRY_ORG: ${{secrets.SENTRY_ORG}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
SENTRY_PROJECT: ${{secrets.SENTRY_PROJECT}}


jobs:
pre-build:
Expand Down Expand Up @@ -44,7 +49,8 @@ jobs:
run: |
scr setup
flutter config --enable-web
flutter build web --release --dart-define=environment=production --pwa-strategy=none --no-web-resources-cdn
flutter build web --release --dart-define=environment=production --dart-define=SENTRY_DSN=${SENTRY_DSN} --dart-define=SENTRY_PROJECT=${SENTRY_PROJECT} --dart-define=SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} --dart-define=SENTRY_ORG=${SENTRY_ORG} --pwa-strategy=none --no-web-resources-cdn
flutter packages pub run sentry_dart_plugin
# Disribute to Firebase
- uses: FirebaseExtended/action-hosting-deploy@v0
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
env:
BUILD_NUMBER: ${{ github.run_number }}
RELEASE_NOTES: Staging - ${{ github.sha }}
SENTRY_DSN: ${{secrets.SENTRY_DSN}}
SENTRY_ORG: ${{secrets.SENTRY_ORG}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
SENTRY_PROJECT: ${{secrets.SENTRY_PROJECT}}

jobs:
pre-build:
Expand Down Expand Up @@ -46,7 +50,8 @@ jobs:
run: |
scr setup
flutter config --enable-web
flutter build web --dart-define=environment=staging --release --pwa-strategy=none --no-web-resources-cdn
flutter build web --dart-define=environment=staging --dart-define=SENTRY_DSN=${SENTRY_DSN} --dart-define=SENTRY_PROJECT=${SENTRY_PROJECT} --dart-define=SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} --dart-define=SENTRY_ORG=${SENTRY_ORG} --release --pwa-strategy=none --no-web-resources-cdn
flutter packages pub run sentry_dart_plugin
# Deploy to github pages
- uses: JamesIves/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/91.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Enhances user interface with new options to create manifests for folders with pending files.
- Introduces a reminder pop-up for users with large drives to encourage snapshot usage, enhancing sync efficiency.
- Provides immediate update visibility when renaming a file or folder.
18 changes: 16 additions & 2 deletions lib/app_shell.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
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';
import 'package:ardrive/components/side_bar.dart';
import 'package:ardrive/gift/reedem_button.dart';
Expand Down Expand Up @@ -60,9 +62,21 @@ class AppShellState extends State<AppShell> {

@override
Widget build(BuildContext context) => BlocBuilder<DrivesCubit, DrivesState>(
builder: (context, _) {
builder: (context, drivesState) {
Widget buildPage(scaffold) => Material(
child: BlocBuilder<SyncCubit, SyncState>(
child: BlocConsumer<SyncCubit, SyncState>(
listener: (context, syncState) async {
if (drivesState is DrivesLoadSuccess) {
if (syncState is! SyncInProgress) {
final promptToSnapshotBloc =
context.read<PromptToSnapshotBloc>();

promptToSnapshotBloc.add(SelectedDrive(
driveId: drivesState.selectedDriveId,
));
}
}
},
builder: (context, syncState) => syncState is SyncInProgress
? Stack(
children: [
Expand Down
49 changes: 47 additions & 2 deletions lib/blocs/create_manifest/create_manifest_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
final TurboUploadService _turboUploadService;
final DriveDao _driveDao;
final PstService _pst;
bool _hasPendingFiles = false;

StreamSubscription? _selectedFolderSubscription;

Expand All @@ -41,11 +42,13 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
required TurboUploadService turboUploadService,
required DriveDao driveDao,
required PstService pst,
required bool hasPendingFiles,
}) : _profileCubit = profileCubit,
_arweave = arweave,
_turboUploadService = turboUploadService,
_driveDao = driveDao,
_pst = pst,
_hasPendingFiles = hasPendingFiles,
super(CreateManifestInitial()) {
if (drive.isPrivate) {
// Extra guardrail to prevent private drives from creating manifests
Expand All @@ -59,6 +62,8 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
rootFolderNode =
await _driveDao.getFolderTree(drive.id, drive.rootFolderId);

_hasPendingFiles = await _hasPendingFilesInFolder(rootFolderNode);

await loadFolder(drive.rootFolderId);
}

Expand All @@ -83,6 +88,40 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
}
}

/// recursively check if any files in the folder have pending uploads
Future<bool> _hasPendingFilesInFolder(FolderNode folder) async {
final files = folder.getRecursiveFiles();
final folders = folder.subfolders;

if (files.isEmpty && folders.isEmpty) {
return false;
}

final filesWithTx = await _driveDao
.filesInFolderWithRevisionTransactions(
driveId: drive.id, parentFolderId: folder.folder.id)
.get();

final hasPendingFiles = filesWithTx.any((e) =>
'pending' ==
fileStatusFromTransactions(
e.metadataTx,
e.dataTx,
).toString());

if (hasPendingFiles) {
return true;
}

for (var folder in folders) {
if (await _hasPendingFilesInFolder(folder)) {
return true;
}
}

return false;
}

Future<void> loadFolder(String folderId) async {
await _selectedFolderSubscription?.cancel();

Expand Down Expand Up @@ -174,7 +213,6 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
(state as CreateManifestPreparingManifest).parentFolder;
final folderNode = rootFolderNode.searchForFolder(parentFolder.id) ??
await _driveDao.getFolderTree(drive.id, parentFolder.id);

final arweaveManifest = ManifestData.fromFolderNode(
folderNode: folderNode,
);
Expand Down Expand Up @@ -211,7 +249,9 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
addManifestToDatabase() => _driveDao.transaction(
() async {
await _driveDao.writeFileEntity(
manifestFileEntity, '${parentFolder.path}/$manifestName');
manifestFileEntity,
'${parentFolder.path}/$manifestName',
);
await _driveDao.insertFileRevision(
manifestFileEntity.toRevisionCompanion(
performedAction: existingManifestFileId == null
Expand All @@ -221,13 +261,17 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
);
},
);

logger.d('Manifest has pending files: $_hasPendingFiles');

final canUseTurbo = _turboUploadService.useTurboUpload &&
arweaveManifest.size < _turboUploadService.allowedDataItemSize;
if (canUseTurbo) {
emit(
CreateManifestTurboUploadConfirmation(
manifestSize: arweaveManifest.size,
manifestName: manifestName,
folderHasPendingFiles: _hasPendingFiles,
manifestDataItems: [manifestDataItem, manifestMetaDataItem],
addManifestToDatabase: addManifestToDatabase,
),
Expand Down Expand Up @@ -275,6 +319,7 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
CreateManifestUploadConfirmation(
manifestSize: arweaveManifest.size,
manifestName: manifestName,
folderHasPendingFiles: _hasPendingFiles,
arUploadCost: arUploadCost,
usdUploadCost: usdUploadCost,
uploadManifestParams: uploadManifestParams,
Expand Down
7 changes: 6 additions & 1 deletion lib/blocs/create_manifest/create_manifest_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class CreateManifestInsufficientBalance extends CreateManifestState {
class CreateManifestUploadConfirmation extends CreateManifestState {
final int manifestSize;
final String manifestName;

final bool folderHasPendingFiles;
final String arUploadCost;
final double? usdUploadCost;

Expand All @@ -100,6 +100,7 @@ class CreateManifestUploadConfirmation extends CreateManifestState {
CreateManifestUploadConfirmation({
required this.manifestSize,
required this.manifestName,
required this.folderHasPendingFiles,
required this.arUploadCost,
required this.usdUploadCost,
required this.uploadManifestParams,
Expand All @@ -109,6 +110,7 @@ class CreateManifestUploadConfirmation extends CreateManifestState {
List get props => [
manifestSize,
manifestName,
folderHasPendingFiles,
arUploadCost,
usdUploadCost,
uploadManifestParams,
Expand All @@ -119,12 +121,14 @@ class CreateManifestUploadConfirmation extends CreateManifestState {
class CreateManifestTurboUploadConfirmation extends CreateManifestState {
final int manifestSize;
final String manifestName;
final bool folderHasPendingFiles;
final List<DataItem> manifestDataItems;
final Future<void> Function() addManifestToDatabase;

CreateManifestTurboUploadConfirmation({
required this.manifestSize,
required this.manifestName,
required this.folderHasPendingFiles,
required this.manifestDataItems,
required this.addManifestToDatabase,
});
Expand All @@ -133,6 +137,7 @@ class CreateManifestTurboUploadConfirmation extends CreateManifestState {
List<Object> get props => [
manifestSize,
manifestName,
folderHasPendingFiles,
manifestDataItems,
addManifestToDatabase,
];
Expand Down
6 changes: 4 additions & 2 deletions lib/blocs/drive_detail/drive_detail_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,13 @@ class DriveDetailCubit extends Cubit<DriveDetailState> {
);
}

void refreshDriveDataTable() {
void refreshDriveDataTable() async {
_refreshSelectedItem = true;

if (state is DriveDetailLoadSuccess) {
emit((state as DriveDetailLoadSuccess).copyWith());
await Future.delayed(const Duration(milliseconds: 100));
emit((state as DriveDetailLoadSuccess)
.copyWith(forceRebuildKey: UniqueKey()));
}
}

Expand Down
6 changes: 6 additions & 0 deletions lib/blocs/drive_detail/drive_detail_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class DriveDetailLoadSuccess extends DriveDetailState {

final List<ArDriveDataTableItem> currentFolderContents;

final Key? forceRebuildKey;

DriveDetailLoadSuccess({
required this.currentDrive,
required this.hasWritePermissions,
Expand All @@ -51,6 +53,7 @@ class DriveDetailLoadSuccess extends DriveDetailState {
required this.driveIsEmpty,
this.selectedItem,
required this.currentFolderContents,
this.forceRebuildKey,
});

DriveDetailLoadSuccess copyWith({
Expand All @@ -69,8 +72,10 @@ class DriveDetailLoadSuccess extends DriveDetailState {
bool? hasFoldersSelected,
ArDriveDataTableItem? selectedItem,
List<ArDriveDataTableItem>? currentFolderContents,
Key? forceRebuildKey,
}) =>
DriveDetailLoadSuccess(
forceRebuildKey: forceRebuildKey ?? this.forceRebuildKey,
selectedItem: selectedItem ?? this.selectedItem,
hasFoldersSelected: hasFoldersSelected ?? this.hasFoldersSelected,
currentDrive: currentDrive ?? this.currentDrive,
Expand Down Expand Up @@ -105,6 +110,7 @@ class DriveDetailLoadSuccess extends DriveDetailState {
_equatableBust,
driveIsEmpty,
multiselect,
forceRebuildKey,
];
SelectedItem? maybeSelectedItem() =>
selectedItems.isNotEmpty ? selectedItems.first : null;
Expand Down
Loading

0 comments on commit b01248c

Please sign in to comment.