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:
2026-03-30 22:22:30 +05:30
parent 6c533614b3
commit 81872070e4
2 changed files with 19 additions and 14 deletions

View File

@@ -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));
}

View File

@@ -75,9 +75,10 @@ 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 {
for (int attempt = 0; attempt < 2; attempt++) {
try {
final ev = await _service.getEventDetails(widget.eventId);
if (!mounted) return;
@@ -85,9 +86,13 @@ class _LearnMoreScreenState extends State<LearnMoreScreen> {
_event = ev;
});
_startAutoScroll();
return; // success
} catch (e) {
// Log for debugging, but don't show error — the pre-loaded data is displayed
debugPrint('_loadFullDetails failed for event ${widget.eventId}: $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
}
}
}
}