diff --git a/packages/neon/neon_files/lib/src/blocs/files.dart b/packages/neon/neon_files/lib/src/blocs/files.dart index 9dbfc9ea916..10877d6976d 100644 --- a/packages/neon/neon_files/lib/src/blocs/files.dart +++ b/packages/neon/neon_files/lib/src/blocs/files.dart @@ -94,28 +94,42 @@ class _FilesBloc extends InteractiveBloc implements FilesBloc { final tasks = BehaviorSubject.seeded(BuiltList()); @override - Future addFavorite(PathUri uri) async { - await wrapAction( - () async => account.client.webdav.proppatch( - uri, - set: const WebDavProp(ocfavorite: 1), - ), - ); - } - - @override - Future copy(PathUri uri, PathUri destination) async { - await wrapAction(() async => account.client.webdav.copy(uri, destination)); + Future refresh() async { + await browser.refresh(); } @override - Future delete(PathUri uri) async { - await wrapAction(() async => account.client.webdav.delete(uri)); + Future uploadFile(PathUri uri, String localPath) async { + await wrapAction( + () async { + final task = FilesUploadTaskIO( + uri: uri, + file: File(localPath), + ); + tasks.add(tasks.value.rebuild((b) => b.add(task))); + await uploadQueue.add(() => task.execute(account.client)); + tasks.add(tasks.value.rebuild((b) => b.remove(task))); + }, + disableTimeout: true, + ); } @override - Future move(PathUri uri, PathUri destination) async { - await wrapAction(() async => account.client.webdav.move(uri, destination)); + Future uploadMemory(PathUri uri, Uint8List bytes, {DateTime? lastModified}) async { + await wrapAction( + () async { + final task = FilesUploadTaskMemory( + uri: uri, + size: bytes.length, + lastModified: lastModified, + bytes: bytes, + ); + tasks.add(tasks.value.rebuild((b) => b.add(task))); + await uploadQueue.add(() => task.execute(account.client)); + tasks.add(tasks.value.rebuild((b) => b.remove(task))); + }, + disableTimeout: true, + ); } @override @@ -153,18 +167,8 @@ class _FilesBloc extends InteractiveBloc implements FilesBloc { } @override - Future refresh() async { - await browser.refresh(); - } - - @override - Future removeFavorite(PathUri uri) async { - await wrapAction( - () async => account.client.webdav.proppatch( - uri, - set: const WebDavProp(ocfavorite: 0), - ), - ); + Future delete(PathUri uri) async { + await wrapAction(() async => account.client.webdav.delete(uri)); } @override @@ -178,36 +182,32 @@ class _FilesBloc extends InteractiveBloc implements FilesBloc { } @override - Future uploadFile(PathUri uri, String localPath) async { + Future move(PathUri uri, PathUri destination) async { + await wrapAction(() async => account.client.webdav.move(uri, destination)); + } + + @override + Future copy(PathUri uri, PathUri destination) async { + await wrapAction(() async => account.client.webdav.copy(uri, destination)); + } + + @override + Future addFavorite(PathUri uri) async { await wrapAction( - () async { - final task = FilesUploadTaskIO( - uri: uri, - file: File(localPath), - ); - tasks.add(tasks.value.rebuild((b) => b.add(task))); - await uploadQueue.add(() => task.execute(account.client)); - tasks.add(tasks.value.rebuild((b) => b.remove(task))); - }, - disableTimeout: true, + () async => account.client.webdav.proppatch( + uri, + set: const WebDavProp(ocfavorite: 1), + ), ); } @override - Future uploadMemory(PathUri uri, Uint8List bytes, {DateTime? lastModified}) async { + Future removeFavorite(PathUri uri) async { await wrapAction( - () async { - final task = FilesUploadTaskMemory( - uri: uri, - size: bytes.length, - lastModified: lastModified, - bytes: bytes, - ); - tasks.add(tasks.value.rebuild((b) => b.add(task))); - await uploadQueue.add(() => task.execute(account.client)); - tasks.add(tasks.value.rebuild((b) => b.remove(task))); - }, - disableTimeout: true, + () async => account.client.webdav.proppatch( + uri, + set: const WebDavProp(ocfavorite: 0), + ), ); }