Replace geofence polling with native Android geofence

This commit is contained in:
Artem Kokos
2026-05-12 11:23:44 +07:00
parent 0a5ef9af17
commit 1963488479
38 changed files with 1099 additions and 1931 deletions

View File

@@ -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();
}