better design,

fix crash when register after logout with user with todos
This commit is contained in:
2018-06-07 18:28:09 +03:00
parent a09d7518b3
commit 293f939ec7
5 changed files with 41 additions and 11 deletions

View File

@@ -103,5 +103,7 @@ export function reset() {
export function logout() { export function logout() {
localStorage.removeItem('jwt'); localStorage.removeItem('jwt');
localStorage.removeItem('lists');
localStorage.removeItem('items');
return { type: LOGOUT }; return { type: LOGOUT };
} }

View File

@@ -102,7 +102,7 @@ li button {
background: none; background: none;
width: 2rem; width: 2rem;
font-size: 1rem; font-size: 1rem;
transition: 0.4s ease-in-out; transition: 0.17s ease-in-out;
overflow: hidden; overflow: hidden;
box-shadow: inset -3px 0 6px -3px rgba(0, 0, 0, 0.3); box-shadow: inset -3px 0 6px -3px rgba(0, 0, 0, 0.3);
} }
@@ -137,11 +137,11 @@ li {
font-weight: 400; font-weight: 400;
flex-grow: 2; flex-grow: 2;
flex-shrink: 1; flex-shrink: 1;
transition: 0.3s ease-in-out; transition: 0.1s ease-in-out;
} }
.todo--input { textarea.todo--input {
background: white; background: #fafafa;
color: black; color: black;
resize: none; resize: none;
border: none; border: none;
@@ -152,12 +152,15 @@ li {
width: 100%; width: 100%;
height: 100%; height: 100%;
max-height: 100%; max-height: 100%;
transition: 0.3s ease-in-out; font-size: 1rem;
transition: 0.1s ease-in-out;
} }
.disabled { .disabled {
width: 0; width: 1rem;
padding: 0.5rem 0; opacity: 0;
padding: 0.5rem 1rem;
border-top: 1px solid #f0f0f0;
} }
.filter { .filter {

View File

@@ -74,13 +74,13 @@ class Todo extends React.Component {
<ButtonBase <ButtonBase
style={{ style={{
justifyContent: 'left', justifyContent: 'left',
paddingLeft: '1.5rem', paddingLeft: '1rem',
borderTop: '1px solid #f0f0f0', borderTop: '1px solid #f0f0f0',
textDecoration: this.props.todo.completed ? 'line-through' : 'none', textDecoration: this.props.todo.completed ? 'line-through' : 'none',
color: this.props.todo.completed ? '#888888' : 'black', color: this.props.todo.completed ? '#888888' : 'black',
}} }}
className="todo" className="todo"
onClick={this.state.hover ? this.props.toggleTodo : null} onClick={this.props.toggleTodo}
> >
{this.props.todo.text} {this.props.todo.text}
</ButtonBase> </ButtonBase>
@@ -102,6 +102,10 @@ class Todo extends React.Component {
style={{ backgroundColor: 'pink' }} style={{ backgroundColor: 'pink' }}
className={deleteClasses.join(' ')} className={deleteClasses.join(' ')}
onClick={this.props.removeTodo} onClick={this.props.removeTodo}
onMouseOver={this.onMouseOver}
onFocus={this.onMouseOver}
onMouseOut={this.onMouseOut}
onBlur={this.onMouseOut}
> >
<DeleteIcon style={icon} /> <DeleteIcon style={icon} />
</ButtonBase>, </ButtonBase>,
@@ -110,6 +114,10 @@ class Todo extends React.Component {
style={{ backgroundColor: 'lightcyan' }} style={{ backgroundColor: 'lightcyan' }}
className={editClasses.join(' ')} className={editClasses.join(' ')}
onClick={this.startEdit} onClick={this.startEdit}
onMouseOver={this.onMouseOver}
onFocus={this.onMouseOver}
onMouseOut={this.onMouseOut}
onBlur={this.onMouseOut}
> >
<EditIcon style={icon} /> <EditIcon style={icon} />
</ButtonBase>, </ButtonBase>,
@@ -117,9 +125,8 @@ class Todo extends React.Component {
return ( return (
<animated.li <animated.li
style={this.props.style} style={this.props.style}
onMouseOver={this.onMouseOver} // onFocus and onBlur triggers when long pressing on smartphones
onFocus={this.onMouseOver} onFocus={this.onMouseOver}
onMouseOut={this.onMouseOut}
onBlur={this.onMouseOut} onBlur={this.onMouseOut}
> >
{ButtonBases} {ButtonBases}

View File

@@ -13,6 +13,7 @@ import {
STOP_EDIT_LIST, STOP_EDIT_LIST,
} from '../actions/lists'; } from '../actions/lists';
import { REMOVE_TODO, ADD_TODO } from '../actions/todos'; import { REMOVE_TODO, ADD_TODO } from '../actions/todos';
import { LOGOUT } from '../actions/user';
export default function lists( export default function lists(
state = { state = {
@@ -27,6 +28,16 @@ export default function lists(
action, action,
) { ) {
switch (action.type) { switch (action.type) {
case LOGOUT:
return {
dirty: true,
fetching: false,
lists: null,
loaded: false,
creating: false,
list: null,
editing: false,
};
case CHANGE_LIST: case CHANGE_LIST:
return { ...state, list: action.list }; return { ...state, list: action.list };
case RECIEVE_LISTS: case RECIEVE_LISTS:

View File

@@ -9,6 +9,7 @@ import {
EDIT_TODO, EDIT_TODO,
} from '../actions/todos'; } from '../actions/todos';
import { REMOVE_LIST } from '../actions/lists'; import { REMOVE_LIST } from '../actions/lists';
import { LOGOUT } from '../actions/user';
export default function todos( export default function todos(
state = { state = {
@@ -19,6 +20,12 @@ export default function todos(
action, action,
) { ) {
switch (action.type) { switch (action.type) {
case LOGOUT:
return {
dirty: true,
fetching: false,
todos: null,
};
case RECIEVE_TODOS: case RECIEVE_TODOS:
return { return {
...state, ...state,