From 2bc3fe24b385c7f7f4d9720d379ded22690866ad Mon Sep 17 00:00:00 2001 From: Jonny Date: Thu, 18 Apr 2019 00:03:28 +0200 Subject: [PATCH] Remove manual clearing of errors Since the errors are now always cleared upon rehydration of the application state, we can now safely remove the api method clearErrors() and also remove calls to this method. --- js/api.js | 13 ------------- js/components/Login.js | 9 +-------- pages/register.js | 9 +-------- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/js/api.js b/js/api.js index f7fff46..7ee1678 100644 --- a/js/api.js +++ b/js/api.js @@ -21,8 +21,6 @@ const actiontypes_userinfo = { 'LOGIN_RESULT_SUCCESS' : 'LOGIN_RESULT_SUCCESS', 'LOGIN_RESULT_ERROR' : 'LOGIN_RESULT_ERROR', - 'CLEAR_ERRORS' : 'CLEAR_ERRORS', - 'LOGOUT' : 'LOGOUT', 'VERIFY_CREDENTIALS' : 'VERIFY_CREDENTIALS', @@ -223,11 +221,6 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => { error : true, errorMessages : action.parameters.errorMessages }); - case actiontypes_userinfo.CLEAR_ERRORS: - return Object.assign({}, state, { - error : false, - errorMessages : [] - }); case actiontypes_userinfo.LOGOUT: deleteRequest(action.state, '/users/sign_out').then(() => { __store.dispatch({ type : actiontypes_userinfo.CLEAR }); @@ -367,12 +360,6 @@ export function verifyCredentials() { } } -export function clearErrors() { - __store.dispatch({ - type: actiontypes_userinfo.CLEAR_ERRORS - }); -} - export function register(username, email, password) { __store.dispatch({ type: actiontypes_userinfo.REGISTER, diff --git a/js/components/Login.js b/js/components/Login.js index 6b8db0e..d92174c 100644 --- a/js/components/Login.js +++ b/js/components/Login.js @@ -3,10 +3,7 @@ import React from 'react'; import {connect} from 'react-redux'; import Router from 'next/router'; -import { - login, - clearErrors -} from '../api'; +import { login } from '../api'; export function Login(props) { return ( @@ -82,10 +79,6 @@ class LoginForm extends React.Component { }; } - componentDidMount() { - clearErrors(); - } - tryLogin(event) { event.preventDefault(); login(this.state.email, this.state.password); diff --git a/pages/register.js b/pages/register.js index 3395c3d..e05f8c5 100644 --- a/pages/register.js +++ b/pages/register.js @@ -15,10 +15,7 @@ import { import { TurniereNavigation } from '../js/components/Navigation'; import { Footer } from '../js/components/Footer'; -import { - register, - clearErrors -} from '../js/api'; +import { register } from '../js/api'; import '../static/everypage.css'; @@ -43,10 +40,6 @@ export default class RegisterPage extends React.Component { class Register extends React.Component { - componentDidMount() { - clearErrors(); - } - render() { return (