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
- 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.
- ~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.
- 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.
Problem description
Dead code cleanup in
hasProgress.tsThe key
${appName}_${runner}_progresswas never written anywhere in the repo, which meanspreviousProgresswas always{}and thecalculatePercentoffset logic was dead code (its condition was never met).Feature description
Changes
hasProgress.ts: RemovedlocalStorageread,calculatePercent, andpreviousProgress. Now returns only[currentProgress].GameCardandGamePage(the only consumers of the 2nd tuple element): now passpreviousProgress: nulltoinstall()(its type already accepts it).What this removes
localStorage.getItem+JSON.parseon every render — sinceuseStatewas used in its eager form, this ran on every render of every component usinghasProgress(eachGameCard, download list item, sidebar, etc.) even though the result was discarded after mount.calculatePercentcomputed a "resume from X%" offset, but its condition (previousProgress.percent) was never truthy, so it never did anything. TheuseCallbackwas also unnecessary.hasProgressreturned a 2-element tuple where the 2nd element was always{}, passed toinstall()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; withnullit 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.