api and storage restructure
This commit is contained in:
@@ -6,34 +6,20 @@ import 'listFiles.dart';
|
||||
import 'listFilesParams.dart';
|
||||
import 'listFilesResponse.dart';
|
||||
|
||||
class ListFilesCache extends RequestCache<ListFilesResponse> {
|
||||
String path;
|
||||
|
||||
class ListFilesCache extends SimpleCache<ListFilesResponse> {
|
||||
ListFilesCache({
|
||||
required void Function(ListFilesResponse) onUpdate,
|
||||
void Function(ListFilesResponse)? onCacheData,
|
||||
void Function(ListFilesResponse)? onNetworkData,
|
||||
void Function(Exception)? onError,
|
||||
required this.path,
|
||||
super.onCacheData,
|
||||
super.onNetworkData,
|
||||
super.onError,
|
||||
required String path,
|
||||
}) : super(
|
||||
RequestCache.cacheNothing,
|
||||
onUpdate,
|
||||
onError: onError ?? RequestCache.ignore,
|
||||
onCacheData: onCacheData,
|
||||
onNetworkData: onNetworkData,
|
||||
cacheTime: RequestCache.cacheNothing,
|
||||
loader: () => ListFiles(ListFilesParams(path)).run(),
|
||||
fromJson: ListFilesResponse.fromJson,
|
||||
onUpdate: onUpdate,
|
||||
) {
|
||||
var bytes = utf8.encode('MarianumMobile-$path');
|
||||
var cacheName = md5.convert(bytes).toString();
|
||||
final cacheName = md5.convert(utf8.encode('MarianumMobile-$path')).toString();
|
||||
start('wd-folder-$cacheName');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ListFilesResponse> onLoad() async {
|
||||
var data = await ListFiles(ListFilesParams(path)).run();
|
||||
return data;
|
||||
}
|
||||
|
||||
@override
|
||||
ListFilesResponse onLocalData(String json) => ListFilesResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user