DevangThakkar / wordle_archive

MIT License
280 stars 159 forks source link

persist & display scores & past solutions #35

Closed no-stack-dub-sack closed 2 years ago

no-stack-dub-sack commented 2 years ago

This PR:

Some of the bigger changes include:

Thanks! Let me know what you think or if you have any questions.

closes #21 closes #29

DevangThakkar commented 2 years ago

Thanks for working on this! I'll take a look and test it out!

DevangThakkar commented 2 years ago

@no-stack-dub-sack I'm getting this error on entering the correct word (or six wrong guesses with 'playing' instead of 'won') .

App.js:400 Uncaught TypeError: Cannot create property 'board' on string 'won'     at App.js:400

I'm on the no-stack-dub-sack:feat/past-win-history branch.

Have you faced this error before? Can you test it out? If it works for you, can you clear the local storage (running localStorage.clear() in the console is one way) and see if it still works?

no-stack-dub-sack commented 2 years ago

@DevangThakkar Sorry about that, please try now... when implementing this feature, I only considered the local development experience and naively did not consider the regression impact of the changes I was making (specifically to the shape of gameStateList stored in local storage).

Before my most recent commit, local storage would have needed to be cleared for my changes to work, which obviously would've erased a user's past win history. I've addressed these changes in the easiest way possible, which is to detect if gameStateList is still an array of strings, and if so, perform a one-time update to the new shape so the rest of the code will work. Obviously if I'd considered this from the beginning, I likely would've added a new local storage item to track board state, so if this "one time update" solution feels icky to you, I can refactor to approach it this way instead. That said, I've done some testing switching from master (with plenty of gameStateList already in local storage) to the new branch and it does seem to be working well.

Some choices were made as far as wins recorded before this feature was implemented:

  1. If a user solved a puzzle before we tracked board state in local storage, show the answer on the first row (since we don't know how many guesses it took them to win)
  2. Along the same lines, as far as #21 is concerned, if a user solved a puzzle before we tracked board state, don't show the score next the the puzzle in the menu (we'll only show the score for puzzles solved after this was implemented)
DevangThakkar commented 2 years ago

Thanks for the fixes, I'll look into it! :D

DevangThakkar commented 2 years ago

I think this looks good - I've tested all potential cases that might cause an issue and I've not found anything that breaks. Thank you so much for working on this, I really appreciate your help!