Skip to content
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

Merged

Conversation

dexonsmith
Copy link
Contributor

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

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
Copy link

github-actions bot commented Feb 9, 2024

Uffizzi Preview deployment-46290 was deleted.

@@ -129,6 +129,8 @@ interface TournamentInterface {
opengotha_standings?: boolean;
}

type EditSaveState = "none" | "saving" | "reload";
Copy link
Contributor Author

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?

Copy link
Member

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")

Copy link
Member

@anoek anoek Feb 9, 2024

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)

Copy link
Contributor Author

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.
@anoek
Copy link
Member

anoek commented Feb 10, 2024

Thanks!

@anoek anoek merged commit c300a2d into online-go:devel Feb 10, 2024
4 checks passed
@dexonsmith dexonsmith deleted the delay-reloading-tournament-when-saving-edits branch February 10, 2024 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Save tournament" request aborted on success, leaving tournament in edit mode
2 participants