d5c8d316c5
CI caught six issues against the new admin slice: - AsyncValue<T> in this Riverpod 3.3.1 codebase exposes `.value` (returns T?), not `.valueOrNull`. Switched the three admin readers to match the established convention (player_bar, queue_screen, now_playing_screen all use `.value`). - home_screen.dart still has ctx.push calls in _albumsRow / _artistsRow (carousel tap handlers) — restored the go_router import that Task 2 over-eagerly removed. - admin_user_edit_sheet.dart had a single-line `if (!await ...) return;` that violated curly_braces_in_flow_control_structures. Wrapped in braces. - admin_quarantine_item.dart doc comment had `<top>` placeholders that the analyzer flagged as unintended HTML. Rephrased without angle brackets. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
72 lines
2.6 KiB
Dart
72 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../models/admin_user.dart';
|
|
import '../shared/widgets/main_app_bar_actions.dart';
|
|
import '../theme/theme_extension.dart';
|
|
import 'admin_providers.dart';
|
|
import 'widgets/admin_request_row.dart';
|
|
|
|
class AdminRequestsScreen extends ConsumerWidget {
|
|
const AdminRequestsScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final fs = Theme.of(context).extension<FabledSwordTheme>()!;
|
|
final requests = ref.watch(adminRequestsProvider);
|
|
// Best-effort lookup for requester usernames. If the users provider
|
|
// hasn't loaded yet, valueOrNull is null and rows fall back to the
|
|
// UUID prefix; no blocking spinner.
|
|
final users = ref.watch(adminUsersProvider).value ?? const <AdminUser>[];
|
|
final usersById = {for (final u in users) u.id: u};
|
|
|
|
return Scaffold(
|
|
backgroundColor: fs.obsidian,
|
|
appBar: AppBar(
|
|
backgroundColor: fs.obsidian,
|
|
elevation: 0,
|
|
title: Text('Requests', style: TextStyle(color: fs.parchment)),
|
|
actions: const [MainAppBarActions(currentRoute: '/admin/requests')],
|
|
),
|
|
body: SafeArea(
|
|
child: requests.when(
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
error: (e, _) =>
|
|
Center(child: Text('$e', style: TextStyle(color: fs.error))),
|
|
data: (rows) {
|
|
if (rows.isEmpty) {
|
|
return Center(
|
|
child: Text('No pending requests.',
|
|
style: TextStyle(color: fs.ash)),
|
|
);
|
|
}
|
|
final notifier = ref.read(adminRequestsProvider.notifier);
|
|
return RefreshIndicator(
|
|
onRefresh: () async =>
|
|
ref.refresh(adminRequestsProvider.future),
|
|
child: ListView.builder(
|
|
itemCount: rows.length,
|
|
itemBuilder: (_, i) {
|
|
final req = rows[i];
|
|
final user = usersById[req.userId];
|
|
final display = user?.username ??
|
|
(req.userId.length >= 8
|
|
? req.userId.substring(0, 8)
|
|
: req.userId);
|
|
return AdminRequestRow(
|
|
key: Key('admin_request_row_${req.id}'),
|
|
request: req,
|
|
requesterDisplay: display,
|
|
onApprove: () => notifier.approve(req.id),
|
|
onReject: () => notifier.reject(req.id),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|