Skip to content

Commit

Permalink
///
Browse files Browse the repository at this point in the history
  • Loading branch information
Haykashen committed Oct 15, 2024
1 parent fe60641 commit f45ef83
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/app/article/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ function Article() {
dispatch(articleActions.load(params.id));
dispatch(commentsActions.load(params.id));
}, [params.id]);

useInit(async () => {
await store.actions.session.remind();
});
const select = useSelector(
state => ({
article: state.article.data,
waiting: state.article.waiting,
comments: state.comments.data,
waitingComments: state.comments.waiting
waitingComments: state.comments.waiting,
replyTo: state.comments.replyTo,
exists: state,
}),
shallowequal,
); // Нужно указать функцию для сравнения свойства объекта, так как хуком вернули объект

console.log('exists',select.exists)
const { t } = useTranslate();

const callbacks = {
Expand Down Expand Up @@ -68,7 +72,19 @@ function Article() {
</Spinner>
<h3 style={{ margin: '30px 0 25px 30px'}}>Комментарии ({select.comments.count})</h3>
<div>{select.comments.items && select.comments.items.map(comment => (<CommentContainer key={comment._id} comment={comment} onReply={handleReply} level={0}/>))} </div>


{!select.replyTo && !select.exists && (
<p style={{ marginLeft: '30px' }}>
<Link
to="/login"
className="comment-warn"
state={{ back: location.pathname + location.search }}
>
Войдите
</Link>
, чтобы иметь возможность комментировать
</p>
)}
</PageLayout>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/store-redux/comments/actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import listToTree from '../../utils/list-to-tree';
import treeToList from '../../utils/tree-to-list';
import axios from 'axios';

export default {
/**
* Загрузка товара
Expand Down

0 comments on commit f45ef83

Please sign in to comment.