同步优化2

This commit is contained in:
DelLevin-Home
2026-05-28 08:28:19 +08:00
parent 7efd03c6ba
commit e2e0b11d3d
2 changed files with 9 additions and 2 deletions

View File

@@ -129,6 +129,7 @@ class _ServerSyncPageState extends State<ServerSyncPage> {
if (value && _isActivated) {
// 开启同步:合并本地与服务端数据
await _prefs.setSyncEnabled(true);
if (!mounted) return;
setState(() => _syncEnabled = true);
if (mounted) ToastUtil.show(context, '正在同步数据...');
await ServerSyncService.instance.syncWithServer();
@@ -142,6 +143,7 @@ class _ServerSyncPageState extends State<ServerSyncPage> {
if (mounted) ToastUtil.show(context, '正在从服务器下载数据...');
final success = await ServerSyncService.instance.downloadToLocal();
await _prefs.setSyncEnabled(false);
if (!mounted) return;
setState(() => _syncEnabled = false);
final provider = context.read<AppProvider>();
await provider.loadMovies();