implemented a 1-minute in-memory cache for the EmergencyNoticeClient to prevent redundant network requests on app resume

This commit is contained in:
2026-07-16 10:47:51 +02:00
parent 7c1f5c06df
commit e349d667d4
3 changed files with 43 additions and 56 deletions
@@ -10,13 +10,9 @@ import '../../api/emergency/emergency_notice_client.dart';
import '../../state/app/modules/settings/bloc/settings_cubit.dart';
/// Wraps the app and surfaces a backend-independent emergency notice on cold
/// start and on resume. Transparent otherwise: renders [child] unchanged and
/// only overlays a dialog when the foreign source has an active message.
///
/// Independent of MarianumConnect and of the login state by design — this is
/// the disaster fallback for when the backend is gone. Any failure to load or
/// parse is swallowed by [EmergencyNoticeClient], so a missing/broken source
/// simply shows nothing.
/// start and resume. Renders [child] unchanged and only overlays a dialog when
/// the foreign source has an active message. Independent of MarianumConnect and
/// the login state by design — the fallback for when the backend is gone.
class EmergencyNoticeGate extends StatefulWidget {
final Widget child;
@@ -28,7 +24,7 @@ class EmergencyNoticeGate extends StatefulWidget {
class _EmergencyNoticeGateState extends State<EmergencyNoticeGate>
with WidgetsBindingObserver {
final EmergencyNoticeClient _client = const EmergencyNoticeClient();
final EmergencyNoticeClient _client = EmergencyNoticeClient();
bool _showing = false;
@override