add admin page, fix no legs infinite load on dashboard
All checks were successful
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 6m49s
Release / web-build (push) Successful in 6m23s
Release / android-build (push) Successful in 16m56s
Release / release-master (push) Successful in 30s
Release / release-dev (push) Successful in 32s

This commit is contained in:
2026-01-02 18:49:14 +00:00
parent 29cecf0ded
commit 2fa66ff9c6
11 changed files with 691 additions and 89 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
@@ -221,6 +223,10 @@ class _MyAppState extends State<MyApp> {
path: '/more/settings',
builder: (context, state) => const SettingsPage(),
),
GoRoute(
path: '/more/admin',
builder: (context, state) => const AdminPage(),
),
GoRoute(
path: '/legs/edit/:id',
builder: (_, state) {
@@ -307,6 +313,7 @@ class _MyHomePageState extends State<MyHomePage> {
bool _fetched = false;
bool _railCollapsed = false;
Timer? _notificationsTimer;
@override
void didChangeDependencies() {
@@ -343,10 +350,28 @@ class _MyHomePageState extends State<MyHomePage> {
if (data.notifications.isEmpty) {
data.fetchNotifications();
}
_startNotificationPolling();
});
});
}
void _startNotificationPolling() {
_notificationsTimer?.cancel();
final auth = context.read<AuthService>();
if (!auth.isLoggedIn) return;
_notificationsTimer = Timer.periodic(const Duration(minutes: 2), (_) async {
if (!mounted) return;
final auth = context.read<AuthService>();
if (!auth.isLoggedIn) return;
final data = context.read<DataService>();
try {
await data.fetchNotifications();
} catch (_) {
// Errors already logged inside data service.
}
});
}
@override
Widget build(BuildContext context) {
final uri = GoRouterState.of(context).uri;
@@ -895,4 +920,10 @@ class _MyHomePageState extends State<MyHomePage> {
_forwardHistory.clear();
context.go(tabDestinations[index]);
}
@override
void dispose() {
_notificationsTimer?.cancel();
super.dispose();
}
}