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;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Event details
|
/// Event details — requiresAuth: false so guests can fetch full details
|
||||||
Future<EventModel> getEventDetails(int eventId) async {
|
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));
|
return EventModel.fromJson(Map<String, dynamic>.from(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,19 +75,24 @@ class _LearnMoreScreenState extends State<LearnMoreScreen> {
|
|||||||
// Data loading
|
// Data loading
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Silently fetch full event details to fill in fields missing from the list
|
/// Fetch full event details to fill in fields missing from the list
|
||||||
/// endpoint (important_information, images, etc.) without showing a loader.
|
/// endpoint (important_information, images, etc.).
|
||||||
Future<void> _loadFullDetails() async {
|
Future<void> _loadFullDetails() async {
|
||||||
try {
|
for (int attempt = 0; attempt < 2; attempt++) {
|
||||||
final ev = await _service.getEventDetails(widget.eventId);
|
try {
|
||||||
if (!mounted) return;
|
final ev = await _service.getEventDetails(widget.eventId);
|
||||||
setState(() {
|
if (!mounted) return;
|
||||||
_event = ev;
|
setState(() {
|
||||||
});
|
_event = ev;
|
||||||
_startAutoScroll();
|
});
|
||||||
} catch (e) {
|
_startAutoScroll();
|
||||||
// Log for debugging, but don't show error — the pre-loaded data is displayed
|
return; // success
|
||||||
debugPrint('_loadFullDetails failed for event ${widget.eventId}: $e');
|
} 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