Skip to content

UX improvement & Bug Fixes #359

Description

@SagiEv

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:

  1. Backend (GamificationUserInfoResponse.java): Add an int longestStreak; field to the gamification user info DTO.
  2. Backend (GamificationController.java): Map gamification.getLongestStreak() to the response in the getUserInfo endpoint.
  3. Frontend (StatsScreen.tsx): Update the longest streak display to correctly read data.userInfo?.longestStreak instead 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:

  1. Backend (TaskService.java): Update the getTasksForUser, getExploreTasksForUser, and getTaskForUser methods to explicitly call the mapper overload that builds progress via taskMapper.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:

  1. Frontend (swipeStore.ts): Add an appendBatch: (items: any[]) => void function to Zustand to push new images onto the dataBatch array without resetting the user's current index.
  2. Frontend (SwipeScreen.tsx): Implement a new fetchNextBatchInBackground function governed by a isFetchingNextBatch state flag to prevent duplicate network calls.
  3. Frontend (SwipeScreen.tsx): In the handleSwipe function, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions