mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-10 18:06:01 +02:00
fix pull ab twice in log (#11699)
The reason for calling `pullAb` twice is that when `pullAb` is called for the first time, `setCurrentName` is also called. In `setCurrentName`, if the current address book has not been initialized, it will also attempt to pull. Because `quiet` is false during the first call and `setCurrentName` is not `await` synchronously, the `abLoading` can prevent the two calls. However, `abLoading` depends on `quiet`, so we need to add a new variable `_abLoadingLock`. Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
parent
1a8e3005cd
commit
9dbb6217f7
1 changed files with 13 additions and 5 deletions
|
@ -775,7 +775,10 @@ abstract class BaseAb {
|
|||
|
||||
final pullError = "".obs;
|
||||
final pushError = "".obs;
|
||||
final abLoading = false.obs;
|
||||
final abLoading = false
|
||||
.obs; // Indicates whether the UI should show a loading state for the address book.
|
||||
var abPulling =
|
||||
false; // Tracks whether a pull operation is currently in progress to prevent concurrent pulls. Unlike abLoading, this is not tied to UI updates.
|
||||
bool initialized = false;
|
||||
|
||||
String name();
|
||||
|
@ -790,17 +793,22 @@ abstract class BaseAb {
|
|||
}
|
||||
|
||||
Future<void> pullAb({quiet = false}) async {
|
||||
debugPrint("pull ab \"${name()}\"");
|
||||
if (abLoading.value) return;
|
||||
if (abPulling) return;
|
||||
abPulling = true;
|
||||
if (!quiet) {
|
||||
abLoading.value = true;
|
||||
pullError.value = "";
|
||||
}
|
||||
initialized = false;
|
||||
debugPrint("pull ab \"${name()}\"");
|
||||
try {
|
||||
initialized = await pullAbImpl(quiet: quiet);
|
||||
} catch (_) {}
|
||||
} catch (e) {
|
||||
debugPrint("Error occurred while pulling address book: $e");
|
||||
} finally {
|
||||
abLoading.value = false;
|
||||
abPulling = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> pullAbImpl({quiet = false});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue