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._requestManager, this.options, this.client, ) { unawaited(refresh()); } final RequestManager _requestManager; 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 { await _requestManager.wrapWebDav>( client.id, 'files-${path.value.join('/')}', files, () async => client.webdav.propfind( path.value.join('/'), prop: WebDavPropWithoutValues.fromBools( davgetcontenttype: true, davgetetag: true, davgetlastmodified: true, nchaspreview: true, ocsize: true, ocfavorite: true, ), depth: '1', ), (final response) => response.toWebDavFiles().sublist(1), emitEmptyCache: true, ); } @override void setPath(final List p) { path.add(p); unawaited(refresh()); } @override void createFolder(final List path) { wrapAction(() async => client.webdav.mkcol(path.join('/'))); } }