part of '../neon_files.dart'; abstract class FilesBrowserBlocEvents { void setPath(final List path); void createFolder(final List path); } abstract class FilesBrowserBlocStates { BehaviorSubject>> get files; BehaviorSubject> get path; } class FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBlocEvents, FilesBrowserBlocStates { FilesBrowserBloc( this.options, this.client, ) { unawaited(refresh()); } final FilesAppSpecificOptions options; final NextcloudClient client; @override void dispose() { unawaited(files.close()); unawaited(path.close()); super.dispose(); } @override BehaviorSubject>> files = BehaviorSubject>>(); @override BehaviorSubject> path = BehaviorSubject>.seeded([]); @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( 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)); } } @override void setPath(final List p) { path.add(p); unawaited(refresh()); } @override void createFolder(final List path) { wrapAction( () async => client.webdav.mkdir( path.join('/'), safe: false, ), ); } }