Skip to content

fix(web): synchronize milestone achievements with database to prevent duplicates#93

Open
Novice47 wants to merge 1 commit into
AnirbansarkarS:mainfrom
Novice47:fix-milestone-dedup
Open

fix(web): synchronize milestone achievements with database to prevent duplicates#93
Novice47 wants to merge 1 commit into
AnirbansarkarS:mainfrom
Novice47:fix-milestone-dedup

Conversation

@Novice47
Copy link
Copy Markdown

Description

This PR addresses the issue where milestone achievements are spammed across multiple devices for a single user.

Cause

Currently, Stats.jsx relies on localStorage to check if a milestone has already been logged. When a user logs in from a new device (or clears browser data), the localStorage key is missing, causing isMilestoneAchieved to return false. This triggers duplicate requests to the backend to log the milestone, which spams the feed.

Solution

  • Added getUserMilestones(userId) helper in activityService.js to fetch all already logged milestones from the database.
    • Implemented syncMilestonesToLocalStorage(milestones) helper in Stats.jsx to synchronize the achievements fetched from the database to the local device's localStorage during initial load.
    • Integrated the database fetch and sync check within loadData() before checkMilestones() runs. This ensures localStorage is seeded with existing achievements, preventing duplicates on new devices.
      Acknowledge: Developed with assistance from Antigravity.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@Novice47 is attempting to deploy a commit to the anirbansarkars' projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant