feat(app): смена сервера API и очистка данных устройства при выходе

Адрес бэкенда хранится в shared_preferences и читается до runApp; switchApiBaseUrl сбрасывает токены и кэш старого сервера. Выход стирает refresh-токен и sqlite-кэш ответов. Экран настроек переделан под разделы.
This commit is contained in:
Dmitry
2026-09-19 22:14:14 +03:00
parent bfe74ca47c
commit a559d6de3e
17 changed files with 887 additions and 135 deletions
+17
View File
@@ -0,0 +1,17 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../config.dart';
import 'auth_controller.dart';
/// Points the app at [url] (null = the default). A different server means a different
/// account, so the session ends first — while the clients still talk to the OLD server, so
/// the refresh token is revoked there and never sent to the new one — and only then is the
/// address changed. Takes a container rather than a `WidgetRef`: signing out replaces the
/// calling screen, and a disposed widget's `ref` throws.
Future<void> switchApiBaseUrl(ProviderContainer container, String? url) async {
final next = url ?? defaultApiBaseUrl();
if (next != container.read(apiBaseUrlProvider)) {
await container.read(authControllerProvider.notifier).logout();
}
await container.read(apiBaseUrlProvider.notifier).save(url);
}