Skip to content

(User) add logout button and authorization check #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: chp13-optimize-re-renders
Choose a base branch
from

Conversation

artbocha
Copy link
Collaborator

@artbocha artbocha commented Aug 7, 2018

No description provided.

@artbocha artbocha requested a review from maxfarseer August 7, 2018 21:24
type: LOGIN_STATUS_REQUEST,
})

// eslint-disable-next-line no-undef
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я добавил в .eslintrc globals VK, теперь можно не выключать строку

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

очень странно, не работает у меня "globals": { "VK": true }, хотя правила работают и плагин Eslint для VSCode тоже нормально срабатывает

dispatch({
type: LOGOUT_REQUEST,
})
// eslint-disable-next-line no-undef
Copy link
Owner

@maxfarseer maxfarseer Aug 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

аналогично (нужно удалить)

const { name, handleLogout, handleLogin, isFetching } = this.props
const authorized = Boolean(name)
const btnName = authorized ? 'Выйти' : 'Войти'
const onClick = authorized ? handleLogout : handleLogin
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return { ...state, isFetching: false, error: action.payload.message }

case t.LOGIN_STATUS_REQUEST:
return { ...state, isFetching: true, error: '' }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно объединить одинаковые case, например:

case t.LOGIN_REQUEST:
case t.LOGIN_STATUS_REQUEST:
case t.LOGOUT_REQUEST:
      return { ...state, isFetching: true, error: '' }

p.s. так же посмотри остальные

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point.
у redux-actions вроде нельзя так сделать, не помнишь ?

return { ...state, isFetching: true, error: '' }

case t.LOGIN_STATUS_SUCCESS:
return { ...state, isFetching: false, error: '', name: action.payload }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я думаю, что если мы на *_REQUEST обнуляем ошибку, то на *_SUCCESS ее уже быть не может и поэтому можно удалить лишний код: error: ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants