refactored data providers with centralized cache resolution, unified UI using custom dialogs and bottom sheets, and enhanced network error handling for Dio and TLS errors
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:nextcloud/nextcloud.dart';
|
||||
import '../../../../../api/marianumcloud/webdav/queries/list_files/list_files_cache.dart';
|
||||
import '../../../../../api/marianumcloud/webdav/queries/list_files/list_files_response.dart';
|
||||
import '../../../../../api/marianumcloud/webdav/webdav_api.dart';
|
||||
import '../../../../../api/request_cache.dart';
|
||||
|
||||
class FilesDataProvider {
|
||||
/// Lists files at [path]. Cached payload is delivered via [onCacheData] as
|
||||
@@ -14,22 +15,17 @@ class FilesDataProvider {
|
||||
String path, {
|
||||
void Function(ListFilesResponse)? onCacheData,
|
||||
void Function(Object)? onError,
|
||||
}) async {
|
||||
ListFilesResponse? latest;
|
||||
Object? capturedError;
|
||||
final cache = ListFilesCache(
|
||||
path: path,
|
||||
onUpdate: (data) => latest = data,
|
||||
onCacheData: onCacheData,
|
||||
onError: (e) {
|
||||
capturedError = e;
|
||||
onError?.call(e);
|
||||
},
|
||||
);
|
||||
await cache.ready;
|
||||
if (latest != null) return latest!;
|
||||
throw capturedError ?? Exception('No data and no error from listFiles');
|
||||
}
|
||||
}) =>
|
||||
resolveFromCache<ListFilesResponse>(
|
||||
(onUpdate, onError) => ListFilesCache(
|
||||
path: path,
|
||||
onUpdate: onUpdate,
|
||||
onCacheData: onCacheData,
|
||||
onError: onError,
|
||||
),
|
||||
onError: onError,
|
||||
operationName: 'listFiles',
|
||||
);
|
||||
|
||||
Future<void> createFolder(String fullPath) async {
|
||||
final webdav = await WebdavApi.webdav;
|
||||
|
||||
Reference in New Issue
Block a user