Personalized game problem

If I have a personalized game model which is different from the model I am creating, in the TITLE and in the rank limit, when I change the handicap from automatic to none, the button “add current settings” is gone, and it is changed to “eliminate”, as if I wanted to delete my other model, instead of creating a CLEARLY DIFFERENT ONE.

Is it impossible to have 2 models that are different in these 2 aspects only? Handicap and rank limit?

3 Likes

It is definitely the case that the code says what you are seeing (just confirming you’re not mistaken, there isn’t anything odd going on) - it’s not differentiating based on rank limit.

This should be “easy fix” :crossed_fingers:

Yes, it seems to be “just” this. I want to have 2 models of creating new game challenges to be sent either as invitation only, or to be putted in the public offers we see (usually I like just the first one), but I want these 2 with different rank limits.

It should be easy to fix, since changing the rank limits does not give me the button to save the changed model (which is new, and it is easy to see that it is, since I will not have models using all possible rank limits, I just have one of them).

If you think it is needed, I can make a test to repeat the issue. Or give more information (not necessary, besides saying I am using a computer browser, at most, I imagine).

Thank you for your attention

When I said “it should be easy to fix” I meant “based on my knowledge of the code, I can see how to fix it, and I hope nothing tricky pops up”.

(As opposed to guessing that it’s easy to fix from thinking about what we see in the UI, which is always a trap - as a rule, nothing is easy :stuck_out_tongue: )

Anyhow, I’ve coded the fix, fingers crossed it tests out OK :crossed_fingers:

3 Likes

I take it back.

It’s more difficult than you could imagine. :sob:

I’d complain about why that is the case, but I’d be typing all night :stuck_out_tongue_closed_eyes:

This piece of OGS code is one of those “very old, we really should re-write it … except it’s so complicated and old that it’s too hard to re-write”

4 Likes

This made me take a look at the source code, but I was immediately turned off by this 2400+ lines file:

At least I learned an interesting way to deepcopy :rofl:

const challenge = JSON.parse(JSON.stringify(this.getChallenge()));

5 Likes

Yay for you for taking a look.

Yes, the size is only the beginning :stuck_out_tongue_closed_eyes:

That huge file also predates a good understanding of both “React state” and “a solid approach to typing”.

online-go.com/src/components/ChallengeModal/ChallengeModal.tsx at 2772457a2cd330651dc7f9c197fbee5a69dc6573 · online-go/online-go.com · GitHub

“Refactors welcome” :angel:t2:

This is the root of lots of contortions in there. Contortions on contortions, like “instead of trying to update the state right now, I’ll read it from the form later, because it’s too scary to update the state” :stuck_out_tongue_closed_eyes:

However there’s PR in for this change now.

Preferred settings - rank restriction support by GreenAsJade · Pull Request #3017 · online-go/online-go.com · GitHub

2 Likes

I miss a simple form to create new challenge models. I prefer it saves duplicate models, instead of not letting me save a new one, similar to one I know I have (and so I load it, to use the similarities). Deleting them is very easy, so I do not care about the eventual duplicates.

What I care is that the list does NOT show everything the model contains. And some details can be important differences, like rank limits.

The dynamic part of Play Go at online-go.com! | OGS to let me create a personalized game has all the bad things a dynamic page can have. Thousands of lines… :roll_eyes::thinking::see_no_evil:

What the heck, OGS already has a util for that!

2 Likes

Just imagine you had to maintain that AND endure complaints about small inconveniences :sweat_smile:

GaJ, what is an example component where the state management is better? I don’t have much experience with React, but maybe I can learn it.

6 Likes

Totally you can :slight_smile:

I think that the Report Modal is a pretty good moderate complexity example.

It shows:

  • Using React.useState for state management
  • Using React.useEffect for data-fetching
  • Posting stuff to the server
3 Likes

It’s perhaps also worth mentioning that we have a system in place now for end to end testing.

Should you actually get to redoing the Challenge Modal, I’d be up to support that with e2e tests, if you’re going to try to make it compatible enough.

4 Likes

Are you saying this last message to someone specific, GreenAsJade? If testing it is easy, I can do that. If several different kinds of uses must be tested too, I may not be able to do them all.

2 Likes

It’s a kind offer, thanks!

There are lots of types of testing we would love to get done.

I was referring to “automated end to end tests”, which are useful to ensure that something complex has not been broken when we change it. A similar tool is “automated unit tests”.

I would not describe either of these as “easy” though.

I think you perhaps have in mind “a human doing testing”, which is also useful of course, and certainly easy: you just need to play go :slight_smile: That would happen when the change gets into beta.online-go.com .

3 Likes

FYI the update to add this is in now (browser tab reload needed).

5 Likes

Thank you for informing us here.

1 Like