Repository: 4ian/GDevelop
File: newIDE/app/src/Profile/AuthenticatedUserProvider.js (JavaScript)

Code before:
          },
        });
      }
    }
    this.setState({
      createAccountInProgress: false,
      loginInProgress: false,
      authenticatedUser: {
        ...this.state.authenticatedUser,
        creatingOrLoggingInAccount: false,
      },
    });
    this._automaticallyUpdateUserProfile = true;
  };

  _cancelLoginOrSignUp = () => {
    if (this._abortController) {
      this._abortController.abort();
      this._abortController = null;
    }
    this.setState({
      loginInProgress: false,
      createAccountInProgress: false,
      authenticatedUser: {
        ...this.state.authenticatedUser,
        creatingOrLoggingInAccount: false,
      },
    });
  };

  _doLogin = async (form: LoginForm) => {
    const { authentication } = this.props;
    if (!authentication) return;

    this.setState({
      loginInProgress: true,
      apiCallError: null,
      authenticatedUser: {
        ...this.state.authenticatedUser,
        creatingOrLoggingInAccount: true,
        authenticationError: null,
      },
    });
    this._automaticallyUpdateUserProfile = false;
    try {
      await authentication.login(form);
      await this._fetchUserProfileWithoutThrowingErrors({ resetState: true });
      this.openLoginDialog(false);
      this._showLoginSnackbar(this.state.authenticatedUser);
    } catch (apiCallError) {
      this.setState({

Review comment (suggestion):
I don't like doing this here. It looks like we're trying to "finish a process". But the process is already there:

<img width="776" alt="image" src="https://github.com/user-attachments/assets/6fe5b8b4-8d4c-4124-b83a-34f6d90bbd83">

There is already a catch (ensuring that an exception will never stop the end to run) and at the end we set the boolean back to false.

Code after:
          },
        });
      }
    }
    this.setState({
      createAccountInProgress: false,
      loginInProgress: false,
      authenticatedUser: {
        ...this.state.authenticatedUser,
        creatingOrLoggingInAccount: false,
      },
    });
    this._automaticallyUpdateUserProfile = true;
  };

  _cancelLoginOrSignUp = () => {
    if (this._abortController) {
      this._abortController.abort();
      this._abortController = null;
    }
  };

  _doLogin = async (form: LoginForm) => {
    const { authentication } = this.props;
    if (!authentication) return;

    this.setState({
      loginInProgress: true,
      apiCallError: null,
      authenticatedUser: {
        ...this.state.authenticatedUser,
        creatingOrLoggingInAccount: true,
        authenticationError: null,
      },
    });
    this._automaticallyUpdateUserProfile = false;
    try {
      await authentication.login(form);
      await this._fetchUserProfileWithoutThrowingErrors({ resetState: true });
      this.openLoginDialog(false);
      this._showLoginSnackbar(this.state.authenticatedUser);
    } catch (apiCallError) {
      this.setState({
        apiCallError,
        authenticatedUser: {
          ...this.state.authenticatedUser,
          authenticationError: apiCallError,
        },
      });
    }
    this.setState({