Repository navigation
fix(client): fix progress download, upload, and completion persistence (#538) - #581
Open
myersdennis94 wants to merge 1 commit into
Open
myersdennis94 wants to merge 1 commit into
myersdennis94 wants to merge 1 commit into
Conversation
Author
|
I just found Lean Game Server recently, thanks for hosting this! I ran into this issue and wanted to help but I'm limited on React experience and don't know the codebase any. As such, I used Gemini in Antigravity to help diagnose and fix, attempting to conform to style and paradigms present within the project. I tried my best to understand all changes but please give everything a thorough lookover. For the curious, I used a mixture of Gemini 3.8 Flash and Gemini 4 Argon inside the Antigravity IDE. Cheers! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…e (#538)Fixes #538
What was wrong
#538):downloadProgressinterpolatedgameId(e.g.g/owner/repo) andnew Date().toLocaleDateString()directly intoa.download, introducing/path separators into the downloaded filename, and did not guard against missinggameId/gameProgress.UploadPopupduplicated the rawdownloadFilecall with the same unsanitized filename instead of reusingdownloadProgress.UploadPopup,setPopup(null)was called synchronously right afterfileReader.readAsText(file)—outsidefileReader.onload—unmountingUploadPopupbeforeonloadcould callsetProgress.JSON.parsehad no error handling or validation for partial/wrappedgame_progressJSON structures, and clicking the upload button lackedev.preventDefault().#465and#492):DualEditorMainwas removed in#492, theuseEffectthat persistedcompleted: true(completedAtom) and unlocked newly proved items (inventoryAtom) onproof?.completedwas dropped, so solving levels never marked them completed or populatedinventoryinlocalStorage.currentInventoryTilesAtomread from an unuseduserInventoryAtominstead ofinventoryAtomand filtered out locked tiles before unlocking items present in the user's inventory.world-tree-atoms.ts,levelsCompletedAtomFamilyhad a stray space in${worldId}: ${i}and only checked0 .. worldSize - 1(skipping the last level of each world), andworldDependenciesCompletedAtomFamilycheckedworldCompletedAtom(worldId)instead of the prerequisite source worldit[0].What this changes
downloadProgressanddownloadFile, sanitizes the download filename (lean4game-<owner_repo>-YYYY-MM-DD.json), revokes the object URL after download, and reusesdownloadProgressinUploadPopup.setPopup(null)insidefileReader.onloadinUploadPopup, validates and normalizes uploaded JSON (supporting both single-gameGameProgressand{ games: { [gameId]: ... } }), and addsev.preventDefault().proof?.completedeffect inPlayableLevel.tsx(guarded by!levelInfoIsLoading && levelInfo?.index === levelIdto avoid premature completion during level transitions as noted in#494) and clearscodeAtomon erase inErasePopup.currentInventoryTilesAtomininventory-atoms.tsand world/level completion lookups inworld-tree-atoms.ts.Erase,Download, andUploadspecs incypress/e2e/01-basic-interface.cy.ts.How it was tested
npx cypress run --spec cypress/e2e/01-basic-interface.cy.ts: 10/10 passing (including downloadinglean4game-test_TestGame-YYYY-MM-DD.jsonand verifying its contents, and uploading a progress JSON file and verifyinglocalStoragepersistence).npx i18next-scanner --config i18next-scanner.config.cjsinclient/: no parse errors on modified components.npm run build:clientsucceeds with zero TypeScript errors.