-
Notifications
You must be signed in to change notification settings - Fork 347
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
Delay reloading tournament when saving edits #2572
Delay reloading tournament when saving edits #2572
Conversation
If the tournament director clicks "Save Tournament" after making edits, when they're accepted by the server, the server will send a PUSH notification on the tournament channel asking all clients to reload before sending back "success". Delay this reloading action until we have a response from the "Save" request. Previously, the reload was aborting the about-to-succeed request, kicking the client back into edit mode. Fixes online-go#2571
Uffizzi Preview |
@@ -129,6 +129,8 @@ interface TournamentInterface { | |||
opengotha_standings?: boolean; | |||
} | |||
|
|||
type EditSaveState = "none" | "saving" | "reload"; |
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.
Not sure this is really providing any type safety benefit when using React's useState. Is there some way to declare a type in useState
that I missed?
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.
Yep like this: React.useState<EditSaveState>("none")
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.
(Once that's in you shouldn't nee dto do any of the "as EditSaveState" stuff in either the useState call or the setEditSaveState)
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, and there are examples of that nearby too... done in 3cb14c6.
Just in case `resolve()` somehow gets interrupted, call `setEditSaveState("none")` first to be sure we're not left in a weird state.
Thanks! |
If the tournament director clicks "Save Tournament" after making edits, when they're accepted by the server, the server will send a PUSH notification on the tournament channel asking all clients to reload before sending back "success".
Delay this reloading action until we have a response from the "Save" request. Previously, the reload was aborting the about-to-succeed request, kicking the client back into edit mode.
Fixes #2571