claude refactorings, flutter best practices, platform dependent changes, general cleanup
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
|
||||
|
||||
import '../../../../apiResponse.dart';
|
||||
import '../../webdavApi.dart';
|
||||
import 'downloadFileParams.dart';
|
||||
|
||||
class DownloadFile extends WebdavApi<DownloadFileParams> {
|
||||
DownloadFileParams params;
|
||||
|
||||
DownloadFile(this.params) : super(params);
|
||||
|
||||
@override
|
||||
Future<ApiResponse> run() async {
|
||||
|
||||
// final file = await File(localPath).create();
|
||||
// Uint8List downloadedFile = await (await WebdavApi.webdav).download(params.webdavPath);
|
||||
// file.writeAsBytesSync(downloadedFile, flush: true, mode: FileMode.write);
|
||||
//
|
||||
// OpenFile.open(localPath);
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
import '../../../../api_response.dart';
|
||||
import '../../webdav_api.dart';
|
||||
import 'download_file_params.dart';
|
||||
|
||||
class DownloadFile extends WebdavApi<DownloadFileParams> {
|
||||
DownloadFileParams params;
|
||||
|
||||
DownloadFile(this.params) : super(params);
|
||||
|
||||
@override
|
||||
Future<ApiResponse> run() async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../../../apiParams.dart';
|
||||
import '../../../../api_params.dart';
|
||||
|
||||
part 'downloadFileParams.g.dart';
|
||||
part 'download_file_params.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class DownloadFileParams extends ApiParams {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'downloadFileParams.dart';
|
||||
part of 'download_file_params.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'downloadFileResponse.g.dart';
|
||||
part 'download_file_response.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class DownloadFileResponse {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'downloadFileResponse.dart';
|
||||
part of 'download_file_response.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
@@ -1,25 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
import '../../../../requestCache.dart';
|
||||
import 'listFiles.dart';
|
||||
import 'listFilesParams.dart';
|
||||
import 'listFilesResponse.dart';
|
||||
|
||||
class ListFilesCache extends SimpleCache<ListFilesResponse> {
|
||||
ListFilesCache({
|
||||
required void Function(ListFilesResponse) onUpdate,
|
||||
super.onCacheData,
|
||||
super.onNetworkData,
|
||||
super.onError,
|
||||
required String path,
|
||||
}) : super(
|
||||
cacheTime: RequestCache.cacheNothing,
|
||||
loader: () => ListFiles(ListFilesParams(path)).run(),
|
||||
fromJson: ListFilesResponse.fromJson,
|
||||
onUpdate: onUpdate,
|
||||
) {
|
||||
final cacheName = md5.convert(utf8.encode('MarianumMobile-$path')).toString();
|
||||
start('wd-folder-$cacheName');
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -1,7 +1,7 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:nextcloud/nextcloud.dart';
|
||||
|
||||
part 'cacheableFile.g.dart';
|
||||
part 'cacheable_file.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class CacheableFile {
|
||||
@@ -15,10 +15,6 @@ class CacheableFile {
|
||||
DateTime? modifiedAt;
|
||||
String? sort;
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
bool currentlyDownloading = false;
|
||||
|
||||
|
||||
CacheableFile({required this.path, required this.isDirectory, required this.name, this.mimeType, this.size, this.eTag, this.createdAt, this.modifiedAt});
|
||||
|
||||
CacheableFile.fromDavFile(WebDavFile file) {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'cacheableFile.dart';
|
||||
part of 'cacheable_file.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
+5
-13
@@ -1,10 +1,10 @@
|
||||
|
||||
import 'package:nextcloud/nextcloud.dart';
|
||||
|
||||
import '../../webdavApi.dart';
|
||||
import 'cacheableFile.dart';
|
||||
import 'listFilesParams.dart';
|
||||
import 'listFilesResponse.dart';
|
||||
import '../../webdav_api.dart';
|
||||
import 'cacheable_file.dart';
|
||||
import 'list_files_params.dart';
|
||||
import 'list_files_response.dart';
|
||||
|
||||
class ListFiles extends WebdavApi<ListFilesParams> {
|
||||
ListFilesParams params;
|
||||
@@ -27,16 +27,8 @@ class ListFiles extends WebdavApi<ListFilesParams> {
|
||||
final webdav = await WebdavApi.webdav;
|
||||
final timeout = _isRoot ? _rootTimeout : _subfolderTimeout;
|
||||
final davFiles = (await webdav.propfind(PathUri.parse(params.path)).timeout(timeout)).toWebDavFiles();
|
||||
var files = davFiles.map(CacheableFile.fromDavFile).toSet();
|
||||
final files = davFiles.map(CacheableFile.fromDavFile).toSet();
|
||||
|
||||
// webdav handles subdirectories wrong, this is a fix
|
||||
// currently this fix is not needed anymore
|
||||
// if(EndpointData().getEndpointMode() == EndpointMode.stage) {
|
||||
// files = files.map((e) { // somehow
|
||||
// e.path = e.path.split("mobile/cloud/remote.php/webdav")[1];
|
||||
// return e;
|
||||
// }).toSet();
|
||||
// }
|
||||
|
||||
// somehow the current working folder is also listed, it is filtered here.
|
||||
files.removeWhere((element) => element.path == '/${params.path}/' || element.path == '/');
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:localstore/localstore.dart';
|
||||
|
||||
import '../../../../../utils/cache_invalidation_bus.dart';
|
||||
import '../../../../request_cache.dart';
|
||||
import 'list_files.dart';
|
||||
import 'list_files_params.dart';
|
||||
import 'list_files_response.dart';
|
||||
|
||||
class ListFilesCache extends SimpleCache<ListFilesResponse> {
|
||||
ListFilesCache({
|
||||
required void Function(ListFilesResponse) onUpdate,
|
||||
super.onCacheData,
|
||||
super.onNetworkData,
|
||||
super.onError,
|
||||
required String path,
|
||||
}) : super(
|
||||
cacheTime: RequestCache.cacheNothing,
|
||||
loader: () => ListFiles(ListFilesParams(path)).run(),
|
||||
fromJson: ListFilesResponse.fromJson,
|
||||
onUpdate: onUpdate,
|
||||
) {
|
||||
start(_documentId(path));
|
||||
}
|
||||
|
||||
static String _documentId(String path) {
|
||||
final cacheName = md5.convert(utf8.encode('MarianumMobile-$path')).toString();
|
||||
return 'wd-folder-$cacheName';
|
||||
}
|
||||
|
||||
/// Drops the cached listing for [path] from local storage so the next
|
||||
/// `listFiles` call cannot serve stale data, and notifies any live
|
||||
/// `_FilesView` for that path via [CacheInvalidationBus] so it refetches
|
||||
/// even while it is sitting in the background of the navigation stack.
|
||||
static Future<void> invalidate(String path) async {
|
||||
await Localstore.instance.collection(RequestCache.collection).doc(_documentId(path)).delete();
|
||||
CacheInvalidationBus.notifyListFiles(path);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../../../apiParams.dart';
|
||||
import '../../../../api_params.dart';
|
||||
|
||||
part 'listFilesParams.g.dart';
|
||||
part 'list_files_params.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class ListFilesParams extends ApiParams {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'listFilesParams.dart';
|
||||
part of 'list_files_params.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
+3
-3
@@ -2,10 +2,10 @@ import 'package:jiffy/jiffy.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../../../../view/pages/files/files.dart';
|
||||
import '../../../../apiResponse.dart';
|
||||
import 'cacheableFile.dart';
|
||||
import '../../../../api_response.dart';
|
||||
import 'cacheable_file.dart';
|
||||
|
||||
part 'listFilesResponse.g.dart';
|
||||
part 'list_files_response.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class ListFilesResponse extends ApiResponse {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'listFilesResponse.dart';
|
||||
part of 'list_files_response.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
Reference in New Issue
Block a user