fix(pairing): pairing flow preempt status read fix
This commit is contained in:
@ -51,6 +51,11 @@ class _DeviceDetailsPageState extends ConsumerState<DeviceDetailsPage> {
|
||||
2.77,
|
||||
3.27,
|
||||
];
|
||||
static const List<Duration> _initialStatusRetryDelays = [
|
||||
Duration(milliseconds: 500),
|
||||
Duration(milliseconds: 1500),
|
||||
Duration(seconds: 3),
|
||||
];
|
||||
|
||||
bool _isExitingPage = false;
|
||||
bool _hasRequestedDisconnect = false;
|
||||
@ -218,7 +223,24 @@ class _DeviceDetailsPageState extends ConsumerState<DeviceDetailsPage> {
|
||||
buttonDeviceId: widget.deviceAddress,
|
||||
);
|
||||
|
||||
final initialStatusResult = await service.readStatus();
|
||||
var initialStatusResult = await service.readStatus();
|
||||
for (final delay in _initialStatusRetryDelays) {
|
||||
if (initialStatusResult.isOk() || !mounted) {
|
||||
break;
|
||||
}
|
||||
|
||||
await Future<void>.delayed(delay);
|
||||
if (!mounted) {
|
||||
break;
|
||||
}
|
||||
|
||||
final bluetooth = ref.read(bluetoothProvider).value;
|
||||
if (bluetooth == null || !isCurrentDeviceConnected(bluetooth)) {
|
||||
break;
|
||||
}
|
||||
|
||||
initialStatusResult = await service.readStatus();
|
||||
}
|
||||
if (!mounted) {
|
||||
await service.dispose();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user