automatically clearing command after submitting

This commit is contained in:
talksik
2019-06-23 15:31:22 -07:00
parent 5a9193c3c9
commit c57cb05679
+9 -6
View File
@@ -8,9 +8,7 @@ import { GoogleLogin } from 'react-google-login';
import { Button } from '@material-ui/core'; import { Button } from '@material-ui/core';
import { Send } from '@material-ui/icons'; import { Send } from '@material-ui/icons';
const INITIAL_STATE = { const INITIAL_COMMAND_STATE = {
googleAccessToken: null,
googleAuthUser: null,
command: 'default', command: 'default',
commandInput: '', commandInput: '',
commandIcon: envVars.DEFAULT_LOGO, commandIcon: envVars.DEFAULT_LOGO,
@@ -20,7 +18,11 @@ const INITIAL_STATE = {
}; };
class MainCommand extends Component { class MainCommand extends Component {
state = INITIAL_STATE; state = {
googleAccessToken: null,
googleAuthUser: null,
...INITIAL_COMMAND_STATE
};
componentWillMount() { componentWillMount() {
gapi.load('client:auth2', () => { gapi.load('client:auth2', () => {
@@ -128,6 +130,7 @@ class MainCommand extends Component {
.replace(/\+/g, '-') .replace(/\+/g, '-')
.replace(/\//g, '_') .replace(/\//g, '_')
.replace(/=+$/, ''); .replace(/=+$/, '');
var sendEmail = gapi.client.gmail.users.messages.send({ var sendEmail = gapi.client.gmail.users.messages.send({
userId: 'me', userId: 'me',
resource: { resource: {
@@ -137,12 +140,12 @@ class MainCommand extends Component {
// raw: message // raw: message
} }
}); });
return sendEmail.execute(function(response) { sendEmail.execute(function(response) {
console.log('Sent the Email!', response); console.log('Sent the Email!', response);
}); });
} }
this.setState(INITIAL_STATE); this.setState(INITIAL_COMMAND_STATE, () => console.log(this.state));
}; };
render() { render() {