fix(app): say it out loud when wake-ups do not work

Registration failures from the distributor were swallowed, so push looked
enabled while nothing arrived. Without wake-ups Android suspends the app
and messages only show up once the user opens it — which looks like broken
delivery even though the relay has them queued.

The failure is now remembered and surfaced in Settings, and the chat list
carries a dismissible line explaining the state.
This commit is contained in:
Julius Joska
2026-08-13 12:23:30 +02:00
parent 9985b79aa6
commit 923a6a01bd
18 changed files with 305 additions and 10 deletions
+29
View File
@@ -1,6 +1,7 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sepot/core/push/push_service.dart';
import 'package:sepot/providers/messaging_provider.dart';
import 'package:sepot/providers/storage_provider.dart';
/// Push vrstva nad messagingem.
final pushServiceProvider = Provider<PushService>((ref) {
@@ -18,3 +19,31 @@ final pushInitProvider = FutureProvider<void>((ref) async {
// re-registruje u relaye po každém startu.
await push.restoreMode();
});
/// Stav budíčků pro chat list. Bez funkčního pushe appka na pozadí spí a
/// zprávy dorazí, až ji uživatel otevře — o tom má vědět dřív, než mu
/// někdo vyčte, že neodpovídá.
enum PushHealth {
/// Budíčky nastavené a bez chyby.
ok,
/// Push vůbec nezapnutý (výchozí stav po instalaci).
off,
/// Distributor registraci odmítl — zapnuto, ale nefunguje.
failed,
}
final pushHealthProvider = FutureProvider<PushHealth>((ref) async {
await ref.watch(pushInitProvider.future);
final push = ref.read(pushServiceProvider);
if (await push.registrationFailed()) return PushHealth.failed;
return await push.currentMode() == 'off' ? PushHealth.off : PushHealth.ok;
});
/// Skryl si uživatel upozornění na chat listu? Rozhodnutí se respektuje —
/// připomínat donekonečna by bylo otravné.
final pushHintDismissedProvider = FutureProvider<bool>((ref) async {
final storage = ref.watch(storageProvider);
return await storage.getSetting<bool>('push_hint_dismissed') ?? false;
});