Skip to content

Remove dead code: unused localStorage key and dead calculatePercent logic in hasProgress #5702

Description

@mglourido

Problem description

Dead code cleanup in hasProgress.ts

The key ${appName}_${runner}_progress was never written anywhere in the repo, which means previousProgress was always {} and the calculatePercent offset logic was dead code (its condition was never met).

Feature description

Changes

  • hasProgress.ts: Removed localStorage read, calculatePercent, and previousProgress. Now returns only [currentProgress].
  • GameCard and GamePage (the only consumers of the 2nd tuple element): now pass previousProgress: null to install() (its type already accepts it).

What this removes

  1. A redundant localStorage.getItem + JSON.parse on every render — since useState was used in its eager form, this ran on every render of every component using hasProgress (each GameCard, download list item, sidebar, etc.) even though the result was discarded after mount.
  2. ~15 lines of dead code: calculatePercent computed a "resume from X%" offset, but its condition (previousProgress.percent) was never truthy, so it never did anything. The useCallback was also unnecessary.
  3. Dishonest API: hasProgress returned a 2-element tuple where the 2nd element was always {}, passed to install() without effect. It now returns only what is actually used.

Alternatives

No response

Additional information

Verification

Behavior is functionally identical — the previous flow with {} did a clear-then-rewrite of the marker; with null it rewrites the same way. No visible change in the app is expected, which confirms this was truly dead code.

Note

This refactor was done in commit a247091 of PR #5656 ; the issue is to evaluate whether the refactor is correct and can be applied in a separate PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestNew feature needs to be implemented.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions