Replace geofence polling with native Android geofence
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../../models/home_config.dart';
|
||||
import '../geofence_task_sync.dart';
|
||||
import '../services/geofence_runtime_store.dart';
|
||||
import '../../auth/providers/auth_providers.dart';
|
||||
import '../../shared/providers/core_providers.dart';
|
||||
|
||||
@@ -22,6 +20,7 @@ class CurrentHomeNotifier extends Notifier<HomeConfig?> {
|
||||
if (state != null) {
|
||||
await _initApi(state!);
|
||||
}
|
||||
await ref.read(geofenceAutomationServiceProvider).syncActiveHome(state);
|
||||
}
|
||||
|
||||
/// Переключиться на другой дом
|
||||
@@ -30,6 +29,7 @@ class CurrentHomeNotifier extends Notifier<HomeConfig?> {
|
||||
await svc.setCurrentHomeId(home.id);
|
||||
state = home;
|
||||
await _initApi(home);
|
||||
await ref.read(geofenceAutomationServiceProvider).syncActiveHome(state);
|
||||
}
|
||||
|
||||
/// Выбрать дом как активный и сразу проверить auth-state.
|
||||
@@ -41,11 +41,9 @@ class CurrentHomeNotifier extends Notifier<HomeConfig?> {
|
||||
try {
|
||||
await switchTo(home);
|
||||
await ref.read(authInfoProvider.notifier).load(failOnError: true);
|
||||
await syncGeofenceTask(ref.read(homesProvider), currentHome: state);
|
||||
} catch (error) {
|
||||
await _restoreSelection(previousHome);
|
||||
ref.read(authInfoProvider.notifier).restore(previousAuthState);
|
||||
await syncGeofenceTask(ref.read(homesProvider), currentHome: state);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +51,7 @@ class CurrentHomeNotifier extends Notifier<HomeConfig?> {
|
||||
Future<void> clear() async {
|
||||
await ref.read(settingsServiceProvider).setCurrentHomeId(null);
|
||||
state = null;
|
||||
await syncGeofenceTask(ref.read(homesProvider), currentHome: null);
|
||||
await ref.read(geofenceAutomationServiceProvider).syncActiveHome(null);
|
||||
}
|
||||
|
||||
/// Инициализировать API-клиент текущим домом
|
||||
@@ -74,6 +72,7 @@ class CurrentHomeNotifier extends Notifier<HomeConfig?> {
|
||||
await svc.setCurrentHomeId(home.id);
|
||||
state = home;
|
||||
await _initApi(home);
|
||||
await ref.read(geofenceAutomationServiceProvider).syncActiveHome(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +95,6 @@ class HomesNotifier extends Notifier<List<HomeConfig>> {
|
||||
|
||||
Future<void> remove(String id) async {
|
||||
await ref.read(settingsServiceProvider).deleteHome(id);
|
||||
await GeofenceRuntimeStore().removeHome(id);
|
||||
await load();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user