refactor: stabilize app bootstrap and polling

This commit is contained in:
Artem Kokos
2026-04-22 23:37:15 +07:00
parent 7c0a2675c6
commit 762d16dc78
5 changed files with 353 additions and 59 deletions

View File

@@ -180,12 +180,20 @@ class _HomesScreenState extends ConsumerState<HomesScreen> {
/// Выбрать дом и перейти на пульт
void _selectHome(BuildContext context, HomeConfig home) async {
await ref.read(currentHomeProvider.notifier).switchTo(home);
await ref.read(authInfoProvider.notifier).load();
if (context.mounted) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const RemoteScreen()),
);
try {
await ref.read(currentHomeProvider.notifier).switchTo(home);
await ref.read(authInfoProvider.notifier).load(failOnError: true);
if (context.mounted) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const RemoteScreen()),
);
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Не удалось выбрать дом: $e')));
}
}
}