ab: add full check in pullAb && sync recent check login

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-08-16 14:35:29 +08:00
parent 6f8483aecd
commit da4679f0ae

View File

@ -46,14 +46,17 @@ class AbModel {
AbModel(this.parent) { AbModel(this.parent) {
if (desktopType == DesktopType.main) { if (desktopType == DesktopType.main) {
Timer.periodic(Duration(milliseconds: 500), (timer) async { Timer.periodic(Duration(milliseconds: 500), (timer) async {
if (_timerCounter++ % 6 == 0) syncFromRecent(); if (_timerCounter++ % 6 == 0) {
if (!gFFI.userModel.isLogin) return;
syncFromRecent();
}
}); });
} }
} }
Future<void> pullAb({force = true, quiet = false}) async { Future<void> pullAb({force = true, quiet = false}) async {
debugPrint("pullAb, force:$force, quiet:$quiet"); debugPrint("pullAb, force:$force, quiet:$quiet");
if (gFFI.userModel.userName.isEmpty) return; if (!gFFI.userModel.isLogin) return;
if (abLoading.value) return; if (abLoading.value) return;
if (!force && initialized) return; if (!force && initialized) return;
DateTime startTime = DateTime.now(); DateTime startTime = DateTime.now();
@ -101,6 +104,9 @@ class AbModel {
peers.add(Peer.fromJson(peer)); peers.add(Peer.fromJson(peer));
} }
} }
if (isFull(false)) {
peers.removeRange(licensedDevices, peers.length);
}
_saveCache(); // save on success _saveCache(); // save on success
} }
} }
@ -442,7 +448,7 @@ class AbModel {
} }
// Be careful with loop calls // Be careful with loop calls
if (syncChanged && push) { if (syncChanged && push) {
pushAb(toastIfSucc: false); pushAb(toastIfSucc: false, toastIfFail: false);
} else if (uiChanged) { } else if (uiChanged) {
peers.refresh(); peers.refresh();
} }