opt.: detect sync conflict

This commit is contained in:
lollipopkit
2023-12-04 14:36:32 +08:00
parent 38cdef9458
commit 22901bb856
14 changed files with 104 additions and 23 deletions

View File

@@ -150,7 +150,14 @@ class BackupPage extends StatelessWidget {
title: Text(l10n.auto),
trailing: StoreSwitch(
prop: Stores.setting.icloudSync,
func: (val) async {
validator: (p0) {
if (p0 && Stores.setting.webdavSync.fetch()) {
context.showSnackBar(l10n.autoBackupConflict);
return false;
}
return true;
},
callback: (val) async {
if (val) {
icloudLoading.value = true;
await ICloud.sync();
@@ -273,24 +280,20 @@ class BackupPage extends StatelessWidget {
},
child: Text(l10n.ok),
),
TextButton(
onPressed: () async {
final result = await Webdav.test(
urlCtrl.text,
userCtrl.text,
pwdCtrl.text,
);
if (result == null) {
context.showSnackBar(l10n.success);
} else {
context.showSnackBar(result);
}
},
child: Text(l10n.test),
),
],
);
if (result == true) {
final result = await Webdav.test(
urlCtrl.text,
userCtrl.text,
pwdCtrl.text,
);
if (result == null) {
context.showSnackBar(l10n.success);
} else {
context.showSnackBar(result);
return;
}
Webdav.changeClient(
urlCtrl.text,
userCtrl.text,
@@ -306,7 +309,22 @@ class BackupPage extends StatelessWidget {
title: Text(l10n.auto),
trailing: StoreSwitch(
prop: Stores.setting.webdavSync,
func: (val) async {
validator: (p0) {
if (p0) {
if (Stores.setting.webdavUrl.fetch().isEmpty ||
Stores.setting.webdavUser.fetch().isEmpty ||
Stores.setting.webdavPwd.fetch().isEmpty) {
context.showSnackBar(l10n.webdavSettingEmpty);
return false;
}
}
if (Stores.setting.icloudSync.fetch()) {
context.showSnackBar(l10n.autoBackupConflict);
return false;
}
return true;
},
callback: (val) async {
if (val) {
webdavLoading.value = true;
await Webdav.sync();

View File

@@ -339,7 +339,7 @@ class _SettingPageState extends State<SettingPage> {
title: Text(l10n.followSystem),
trailing: StoreSwitch(
prop: _setting.useSystemPrimaryColor,
func: (_) => setState(() {}),
callback: (_) => setState(() {}),
),
)
];
@@ -747,7 +747,7 @@ class _SettingPageState extends State<SettingPage> {
title: Text(l10n.fullScreen),
trailing: StoreSwitch(
prop: _setting.fullScreen,
func: (_) => RebuildNodes.app.rebuild(),
callback: (_) => RebuildNodes.app.rebuild(),
),
);
}

View File

@@ -30,7 +30,7 @@ class PlatformPublicSettings {
trailing: can == true
? StoreSwitch(
prop: Stores.setting.useBioAuth,
func: (val) async {
callback: (val) async {
if (val) {
Stores.setting.useBioAuth.put(false);
return;