ryanmio / DecodeMe-

DecodeMe! is a coding game with integrated language model.
https://decodeme.app/
MIT License
2 stars 0 forks source link

Fix: Ensure CustomInstructionsIndicator updates for Play Similar feature #73

Closed ryanmio closed 9 months ago

ryanmio commented 9 months ago

This commit addresses an issue where the CustomInstructionsIndicator component was not updating in response to changes made for the "Play Similar" feature. Previously, the component did not react to updates in local storage that indicate the user's choice to play similar scripts, especially after a game was over. This was due to the component not listening for custom events that signal such changes.

Changes made include:

  1. Implementing a custom event dispatch in the usePlaySimilar hook. This event is fired whenever the "Play Similar" feature is activated, and local storage is updated with the selected script and the indication to play similar scripts.

  2. Adding an event listener in the CustomInstructionsIndicator component for the custom event. This listener updates the component's state based on the event's detail, ensuring that the component re-renders with the correct information.

  3. Ensuring cleanup of the event listener on component unmount to prevent memory leaks.

With these changes, the CustomInstructionsIndicator now correctly reflects the user's intent to play similar scripts, enhancing the user experience by providing relevant custom instructions.

netlify[bot] commented 9 months ago

Deploy Preview for decode-me ready!

Name Link
Latest commit 0fd0200c589c346577db0dd9de75e0a594becd46
Latest deploy log https://app.netlify.com/sites/decode-me/deploys/65c18182a10c7100082143b5
Deploy Preview https://deploy-preview-73--decode-me.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.