fix: ensure important information loads for all events (guest + auth)
Changed getEventDetails to requiresAuth: false so guests can fetch full event details without auth tokens. Added retry logic (2 attempts with 1s delay) to _loadFullDetails for reliability on slow networks. This ensures important_information, images, and other detail-only fields are always fetched in the background after initial display. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -77,9 +77,9 @@ class EventsService {
|
||||
return list;
|
||||
}
|
||||
|
||||
/// Event details
|
||||
/// Event details — requiresAuth: false so guests can fetch full details
|
||||
Future<EventModel> getEventDetails(int eventId) async {
|
||||
final res = await _api.post(ApiEndpoints.eventDetails, body: {'event_id': eventId}, requiresAuth: true);
|
||||
final res = await _api.post(ApiEndpoints.eventDetails, body: {'event_id': eventId}, requiresAuth: false);
|
||||
return EventModel.fromJson(Map<String, dynamic>.from(res));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,19 +75,24 @@ class _LearnMoreScreenState extends State<LearnMoreScreen> {
|
||||
// Data loading
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Silently fetch full event details to fill in fields missing from the list
|
||||
/// endpoint (important_information, images, etc.) without showing a loader.
|
||||
/// Fetch full event details to fill in fields missing from the list
|
||||
/// endpoint (important_information, images, etc.).
|
||||
Future<void> _loadFullDetails() async {
|
||||
try {
|
||||
final ev = await _service.getEventDetails(widget.eventId);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_event = ev;
|
||||
});
|
||||
_startAutoScroll();
|
||||
} catch (e) {
|
||||
// Log for debugging, but don't show error — the pre-loaded data is displayed
|
||||
debugPrint('_loadFullDetails failed for event ${widget.eventId}: $e');
|
||||
for (int attempt = 0; attempt < 2; attempt++) {
|
||||
try {
|
||||
final ev = await _service.getEventDetails(widget.eventId);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_event = ev;
|
||||
});
|
||||
_startAutoScroll();
|
||||
return; // success
|
||||
} catch (e) {
|
||||
debugPrint('_loadFullDetails attempt ${attempt + 1} failed for event ${widget.eventId}: $e');
|
||||
if (attempt == 0) {
|
||||
await Future.delayed(const Duration(seconds: 1)); // wait before retry
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user