Repository navigation
UX improvement & Bug Fixes #359
Description
Bug Fix Implementation Plan
Based on an investigation of the repository, here is the plan to resolve the three bugs you're seeing in production.
1. Stats Screen (Current & Longest Streak always 0)
Root Cause:
The StatsScreen tries to read data.userInfo?.currentStreak and data.summary?.summary?.longestStreak. However, the analytics endpoint (AnalyticsService.getUserStatistics()) currently hardcodes the streaks to 0. While currentStreak is already available from the gamification API (/api/v1/gamification/user-info), longestStreak is entirely missing from its response DTO.
Proposed Fix:
- Backend (
GamificationUserInfoResponse.java): Add anint longestStreak;field to the gamification user info DTO. - Backend (
GamificationController.java): Mapgamification.getLongestStreak()to the response in thegetUserInfoendpoint. - Frontend (
StatsScreen.tsx): Update the longest streak display to correctly readdata.userInfo?.longestStreakinstead of the hardcoded analytics placeholder.
2. Tasks Screen (0 images classified, 0% progress)
Root Cause:
In the tasks screen (UserMyTasksScreen.tsx), the progress calculation relies on the progress field embedded in TaskResponse.
However, in TaskService.java inside the backend, the methods fetching tasks for the user (getTasksForUser, getExploreTasksForUser, getTaskForUser) use a TaskMapper.toResponse(task, assignedToUser) overload that defaults to injecting a TaskProgressResponse.empty() object. This hardcodes both totalImages and imagesClassified to 0.
Proposed Fix:
- Backend (
TaskService.java): Update thegetTasksForUser,getExploreTasksForUser, andgetTaskForUsermethods to explicitly call the mapper overload that builds progress viataskMapper.toResponse(task, isAssigned, buildProgress(task.getId())).
3. Seamless Batch Fetching (No endless images stream feeling)
Root Cause:
The swipe handler in SwipeScreen.tsx currently triggers fetchNextBatch only when the user exhausts the current batch (currentIndex + 1 >= dataBatch.length). This abruptly stops the flow and forces a loading screen (or requires clicking "Load More").
Proposed Fix:
- Frontend (
swipeStore.ts): Add anappendBatch: (items: any[]) => voidfunction to Zustand to push new images onto thedataBatcharray without resetting the user's current index. - Frontend (
SwipeScreen.tsx): Implement a newfetchNextBatchInBackgroundfunction governed by aisFetchingNextBatchstate flag to prevent duplicate network calls. - Frontend (
SwipeScreen.tsx): In thehandleSwipefunction, check if the remaining cards fall below a threshold (dataBatch.length - (currentIndex + 1) <= 3). If so, trigger the background fetch asynchronously to fetch the next set of images seamlessly before the user runs out.
Activity