28 lines
768 B
Dart
28 lines
768 B
Dart
import 'dart:convert';
|
|
import 'package:crypto/crypto.dart';
|
|
|
|
import '../../../../requestCache.dart';
|
|
import 'listFiles.dart';
|
|
import 'listFilesParams.dart';
|
|
import 'listFilesResponse.dart';
|
|
|
|
class ListFilesCache extends RequestCache<ListFilesResponse> {
|
|
String path;
|
|
|
|
ListFilesCache({required onUpdate, required this.path}) : super(RequestCache.cacheNothing, onUpdate) {
|
|
var bytes = utf8.encode('MarianumMobile-$path');
|
|
var cacheName = md5.convert(bytes).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));
|
|
|
|
}
|