-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the UNO button functioning #166
Make the UNO button functioning #166
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frontend/src/pages/Game.tsx
Outdated
if (gameState?.players) { | ||
modal.show(<GamePropertiesModal />, 'large', [], false); | ||
} | ||
// eslint-disable-next-line | ||
}, [gameState]); | ||
}, [gameState?.players.length, gameState.id]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to make the dependency array empty. So that the modal pops up only once at the start of the game.
In a different PR, we are introducing a button to show the modal in the middle of the game, and are also adding more options to the modal.
So this modal will be automatically shown once, when the user joins. The if statement is therefore not required too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we need to show the number of players joined so it will update only if the modal is updated following a change in length of players array and also for the one who joins the game game id also changes(from null) so to show the game id we need to reload the modal .
We can incorporate a creator or admin in game and instead of showing Start Game , can show Username's Room Created ! , and the players that join will see Join Username's Room?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points.
- We do want the modal content to change based on some changes to game state. Also, we only need to change the content if the modal is in display in the first place. I think we'd want to update the content on
JOIN_GAME
(since player count increases) andSTART_GAME
(we'd want to close the modal once the admin starts the game). - The change of gameId from null to a value won't be visible to the modal, since i have added a commit which mounts the Game component (of which the modal is a part) only after we have a non-null game id. So we dont need to worry about re-rendering the modal then.
- A room is created the moment a user clicks on Create Game. We can show a toast saying "Room Created!"
- Once the joining players have opened a room, it wouldn't make much sense asking them if they want to join. If they didn't, they wouldn't have entered the game code / clicked on the url.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should improve the modal system to be able to efficiently handle dynamic content.
The current implementation is such that if the user has opened some other modal (like rules etc) and someone joins the game, the GamePropertiesModal will pop up abruptly. That is just bad UX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's something we can do -
-
Remove the dependencies from this useEffect, so that it only appears once when the game page loads (with valid game data)
-
Make the following changes to the modal context -
-
Add a field
id
to uniquely identify each modal. We pass the id when callingmodal.show
-
Add a function to only change the content of the modal if the modal of given id is rendering.
So sth likemodal.setContent("abc",<p>hii</p>
will only set the content tohii
if a modal with idabc
is already visible on the screen. -
Then here, in this modal.show call, we pass in the id for this modal (say "gameProperties")
-
Add another useEffect which calls
modal.setContent("gameProperties",<...>)
and include in its dependency array gameState.players etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree that joining player will see different content in this way
75992ee
to
b8dd895
Compare
frontend/src/pages/Game.tsx
Outdated
modal.show(<GamePropertiesModal />, 'large', [], false); | ||
} | ||
// eslint-disable-next-line | ||
}, [gameState]); | ||
}, []); // todo :Fix the dependency array | ||
const announceGame = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can better be called as announceUNO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a minor comment. Also please amend the commit message to match the format
There's also a merge conflict to be resolved
b8dd895
to
074dacc
Compare
074dacc
to
8a7e8e6
Compare
8a7e8e6
to
9ae54fb
Compare
Set uno button to trigger Announce_Uno Event Also added a handler for this event Fixes : shivansh-bhatnagar18#159
9ae54fb
to
c49895b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Making the uno button functioning
Set uno button to trigger Announce_Uno Event and added a handler for this event" -m
Fixes : #159
Checklist
Screenshots (if applicable)
[If your changes include any visual updates, provide screenshots here.]