implemented native share intent support for android and ios with chat and folder pickers
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import '../../../../../api/errors/error_mapper.dart';
|
||||
import '../../../../../api/marianumcloud/webdav/queries/list_files/list_files_response.dart';
|
||||
import '../../../infrastructure/loadable_state/loading_error.dart';
|
||||
@@ -53,12 +55,24 @@ class FilesBloc
|
||||
Future<void> _query(List<String> path) async {
|
||||
final pathString = path.isEmpty ? '/' : path.join('/');
|
||||
|
||||
// Drop late results when [setPath] has navigated elsewhere or when the
|
||||
// bloc has been disposed (e.g. share-flow picker closed mid-fetch). Both
|
||||
// would otherwise corrupt state or hit "add after close" on the stream.
|
||||
const pathEquality = ListEquality<String>();
|
||||
bool isStale() {
|
||||
if (isClosed) return true;
|
||||
final inner = innerState;
|
||||
if (inner == null) return false;
|
||||
return !pathEquality.equals(inner.currentPath, path);
|
||||
}
|
||||
|
||||
Object? capturedError;
|
||||
ListFilesResponse? listing;
|
||||
try {
|
||||
listing = await repo.data.listFiles(
|
||||
pathString,
|
||||
onCacheData: (cached) {
|
||||
if (isStale()) return;
|
||||
// Cached payload arrives before the network call settles. Surface it
|
||||
// immediately via Emit so the listing is visible while isLoading
|
||||
// stays true and the top loading bar keeps spinning.
|
||||
@@ -73,6 +87,8 @@ class FilesBloc
|
||||
capturedError = e;
|
||||
}
|
||||
|
||||
if (isStale()) return;
|
||||
|
||||
if (listing != null) {
|
||||
listing.files.removeWhere(
|
||||
(file) => file.name.isEmpty || file.name == path.lastOrNull,
|
||||
|
||||
Reference in New Issue
Block a user