Add watch functions to textfields
This commit is contained in:
parent
8cb8bab4a9
commit
e81431d676
|
@ -10956,7 +10956,8 @@
|
|||
"mdi-material-ui": {
|
||||
"version": "5.11.0",
|
||||
"resolved": "https://registry.npmjs.org/mdi-material-ui/-/mdi-material-ui-5.11.0.tgz",
|
||||
"integrity": "sha512-9fIvdiKCKAfBoW11LqZsgaxZtu9WCQEd8FL9/8ceLHvStSf+fZM6sC7exwXaXZmzfwtJMfN1KiMGsPBPSTQFQg=="
|
||||
"integrity": "sha512-9fIvdiKCKAfBoW11LqZsgaxZtu9WCQEd8FL9/8ceLHvStSf+fZM6sC7exwXaXZmzfwtJMfN1KiMGsPBPSTQFQg==",
|
||||
"dev": true
|
||||
},
|
||||
"mdn-data": {
|
||||
"version": "1.1.4",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { Component } from 'react';
|
||||
import React, { Component, ChangeEvent } from 'react';
|
||||
import {withStyles, Paper, Typography, Button, TextField, Fade, Link, CircularProgress, Tooltip, Dialog, DialogTitle, DialogActions, DialogContent} from '@material-ui/core';
|
||||
import {styles} from './WelcomePage.styles';
|
||||
import Mastodon from 'megalodon';
|
||||
|
@ -82,6 +82,16 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
|
|||
})
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (localStorage.getItem("login")) {
|
||||
this.getSavedSession();
|
||||
this.setState({
|
||||
foundSavedLogin: true
|
||||
})
|
||||
this.checkForToken();
|
||||
}
|
||||
}
|
||||
|
||||
updateUserInfo(user: string) {
|
||||
this.setState({ user });
|
||||
}
|
||||
|
@ -102,16 +112,6 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
|
|||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (localStorage.getItem("login")) {
|
||||
this.getSavedSession();
|
||||
this.setState({
|
||||
foundSavedLogin: true
|
||||
})
|
||||
this.checkForToken();
|
||||
}
|
||||
}
|
||||
|
||||
getSavedSession() {
|
||||
let loginData = localStorage.getItem("login");
|
||||
if (loginData) {
|
||||
|
@ -140,6 +140,16 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
|
|||
}
|
||||
}
|
||||
|
||||
watchUsernameField(event: any) {
|
||||
if (event.keyCode === 13)
|
||||
this.startLogin()
|
||||
}
|
||||
|
||||
watchAuthField(event: any) {
|
||||
if (event.keyCode === 13)
|
||||
this.authorizeEmergencyLogin()
|
||||
}
|
||||
|
||||
getLoginUser(user: string) {
|
||||
if (user.includes("@")) {
|
||||
if (this.state.federates) {
|
||||
|
@ -313,6 +323,7 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
|
|||
fullWidth
|
||||
placeholder="example@mastodon.example"
|
||||
onChange={(event) => this.updateUserInfo(event.target.value)}
|
||||
onKeyDown={(event) => this.watchUsernameField(event)}
|
||||
error={this.state.userInputError}
|
||||
onBlur={() => this.checkForErrors()}
|
||||
></TextField>
|
||||
|
@ -405,6 +416,7 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
|
|||
label="Authorization code"
|
||||
fullWidth
|
||||
onChange={(event) => this.updateAuthCode(event.target.value)}
|
||||
onKeyDown={(event) => this.watchAuthField(event)}
|
||||
></TextField>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
|
Loading…
Reference in New Issue