Merge pull request #223 from hyperspacedev/GH-208-input-error-state

Don't show input error state when not empty
This commit is contained in:
Travis Kohlbeck 2020-07-08 18:39:26 -04:00 committed by GitHub
commit 914ee67d95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{
"name": "hyperspace",
"productName": "Hyperspace Desktop",
"version": "1.1.3",
"version": "1.1.4",
"description": "A beautiful, fluffy client for the fediverse",
"author": "Marquis Kurt <hyperspacedev@marquiskurt.net>",
"repository": "https://github.com/hyperspacedev/hyperspace.git",

View File

@ -1,5 +1,5 @@
{
"version": "1.1.3",
"version": "1.1.4",
"location": "https://hyperspaceapp.herokuapp.com",
"branding": {
"name": "Hyperspace",

View File

@ -285,6 +285,7 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
* @param user The string to update the state to
*/
updateUserInfo(user: string) {
this.checkForErrors(user);
this.setState({ user });
}
@ -415,7 +416,7 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
*/
startLogin() {
// Check if we have errored
let error = this.checkForErrors();
let error = this.checkForErrors(this.state.user);
// If we didn't, create the Hyperspace app to register onto that Mastodon
// server.
@ -535,20 +536,20 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
/**
* Check the user input string for any possible errors
*/
checkForErrors(): boolean {
checkForErrors(username: string): boolean {
let userInputError = false;
let userInputErrorMessage = "";
// Is the user string blank?
if (this.state.user === "") {
if (username === "") {
userInputError = true;
userInputErrorMessage = "Username cannot be blank.";
this.setState({ userInputError, userInputErrorMessage });
return true;
} else {
if (this.state.user.includes("@")) {
if (username.includes("@")) {
if (this.state.federates && this.state.federates === true) {
let baseUrl = this.state.user.split("@")[1];
let baseUrl = username.split("@")[1];
// Is the user's domain in the disallowed list?
if (inDisallowedDomains(baseUrl)) {
@ -581,7 +582,7 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
});
}
} else if (
this.state.user.includes(
username.includes(
this.state.registerBase ?? "mastodon.social"
)
) {
@ -772,7 +773,6 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
onChange={event => this.updateUserInfo(event.target.value)}
onKeyDown={event => this.watchUsernameField(event)}
error={this.state.userInputError}
onBlur={() => this.checkForErrors()}
InputProps={{
startAdornment: (
<InputAdornment position="start">@</InputAdornment>