diff --git a/packages/neon/neon_files/lib/blocs/browser.dart b/packages/neon/neon_files/lib/blocs/browser.dart index 0f6ccc09..b19486bb 100644 --- a/packages/neon/neon_files/lib/blocs/browser.dart +++ b/packages/neon/neon_files/lib/blocs/browser.dart @@ -14,12 +14,14 @@ abstract class FilesBrowserBlocStates { class FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBlocEvents, FilesBrowserBlocStates { FilesBrowserBloc( + this._requestManager, this.options, this.client, ) { unawaited(refresh()); } + final RequestManager _requestManager; final FilesAppSpecificOptions options; final NextcloudClient client; @@ -38,26 +40,23 @@ class FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBlocEvents @override Future refresh() async { - // TODO: We have to do this manually, because we can't cache WebDAV stuff right now - try { - files.add(Result.loading()); - final data = await client.webdav.ls( + await _requestManager.wrapWebDav>( + client.id, + 'files-${path.value.join('/')}', + files, + () async => client.webdav.ls( path.value.join('/'), - props: { - WebDavProps.davContentType.name, - WebDavProps.davETag.name, - WebDavProps.davLastModified.name, - WebDavProps.ncHasPreview.name, - WebDavProps.ocSize.name, - WebDavProps.ocFavorite.name, - }, - ); - files.add(Result.success(data)); - } catch (e, s) { - debugPrint(e.toString()); - debugPrint(s.toString()); - files.add(Result.error(e)); - } + prop: WebDavPropfindProp( + davgetcontenttype: true, + davgetetag: true, + davgetlastmodified: true, + nchaspreview: true, + ocsize: true, + ocfavorite: true, + ), + ), + (final response) => response.toWebDavFiles(client.webdav), + ); } @override diff --git a/packages/neon/neon_files/lib/blocs/files.dart b/packages/neon/neon_files/lib/blocs/files.dart index addadd7f..c6fe28a7 100644 --- a/packages/neon/neon_files/lib/blocs/files.dart +++ b/packages/neon/neon_files/lib/blocs/files.dart @@ -30,6 +30,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta FilesBloc( this.options, this.client, + this._requestManager, this._platform, ) { options.uploadQueueParallelism.stream.listen((final value) { @@ -42,6 +43,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta final FilesAppSpecificOptions options; final NextcloudClient client; + final RequestManager _requestManager; final NeonPlatform _platform; late final browser = getNewFilesBrowserBloc(); @@ -64,7 +66,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta @override void addFavorite(final List path) { - wrapAction(() async => client.webdav.updateProps(path.join('/'), {WebDavProps.ocFavorite.name: '1'})); + wrapAction(() async => client.webdav.updateProps(path.join('/'), WebDavProp(ocfavorite: 1))); } @override @@ -120,7 +122,7 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta wrapAction( () async => client.webdav.updateProps( path.join('/'), - {WebDavProps.ocFavorite.name: '0'}, + WebDavProp(ocfavorite: 0), ), ); } @@ -193,5 +195,5 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta } } - FilesBrowserBloc getNewFilesBrowserBloc() => FilesBrowserBloc(options, client); + FilesBrowserBloc getNewFilesBrowserBloc() => FilesBrowserBloc(_requestManager, options, client); } diff --git a/packages/neon/neon_files/lib/neon_files.dart b/packages/neon/neon_files/lib/neon_files.dart index 238da87b..e823d59c 100644 --- a/packages/neon/neon_files/lib/neon_files.dart +++ b/packages/neon/neon_files/lib/neon_files.dart @@ -51,6 +51,7 @@ class FilesApp extends AppImplementation { FilesBloc buildBloc(final NextcloudClient client) => FilesBloc( options, client, + requestManager, platform, ); diff --git a/packages/neon/neon_files/lib/utils/upload_task.dart b/packages/neon/neon_files/lib/utils/upload_task.dart index 0c7897fc..9299b0d2 100644 --- a/packages/neon/neon_files/lib/utils/upload_task.dart +++ b/packages/neon/neon_files/lib/utils/upload_task.dart @@ -24,6 +24,7 @@ class UploadTask { return Uint8List.fromList(chunk); }), path.join('/'), + lastModified: lastModified, ); } }