Improve WebDAV: add auto sync option and improve settings UI (#203)

This commit is contained in:
buste
2025-02-18 22:22:09 +08:00
committed by GitHub
parent 5fb0d2327d
commit 0c54a9be11
3 changed files with 46 additions and 33 deletions

View File

@@ -40,15 +40,19 @@ class DataSync with ChangeNotifier {
bool get isEnabled {
var config = appdata.settings['webdav'];
return config is List && config.isNotEmpty;
var autoSync = appdata.settings['webdavAutoSync'] ?? false;
return autoSync && config is List && config.isNotEmpty;
}
List<String>? _validateConfig() {
var config = appdata.settings['webdav'];
if (config is! List || (config.isNotEmpty && config.length != 3)) {
if (config is! List) {
return null;
}
if (config.whereType<String>().length != 3) {
if (config.isEmpty) {
return [];
}
if (config.length != 3 || config.whereType<String>().length != 3) {
return null;
}
return List.from(config);