part of '../neon_files.dart'; abstract interface class FilesBrowserBlocEvents { void setPath(final PathUri uri); void createFolder(final PathUri uri); } abstract interface class FilesBrowserBlocStates { BehaviorSubject>> get files; BehaviorSubject get uri; } class FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBlocEvents, FilesBrowserBlocStates { FilesBrowserBloc( this.options, this.account, { final PathUri? initialPath, }) { if (initialPath != null) { uri.add(initialPath); } unawaited(refresh()); } final FilesAppSpecificOptions options; final Account account; @override void dispose() { unawaited(files.close()); unawaited(uri.close()); super.dispose(); } @override BehaviorSubject>> files = BehaviorSubject>>(); @override BehaviorSubject uri = BehaviorSubject.seeded(PathUri.cwd()); @override Future refresh() async { await RequestManager.instance.wrapWebDav>( account.id, 'files-${uri.value.path}', files, () => account.client.webdav.propfind( uri.value, prop: WebDavPropWithoutValues.fromBools( davgetcontenttype: true, davgetetag: true, davgetlastmodified: true, nchaspreview: true, ocsize: true, ocfavorite: true, ), depth: WebDavDepth.one, ), (final response) => response.toWebDavFiles().sublist(1), emitEmptyCache: true, ); } @override void setPath(final PathUri uri) { this.uri.add(uri); unawaited(refresh()); } @override void createFolder(final PathUri uri) { wrapAction(() async => account.client.webdav.mkcol(uri)); } }