1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-26 05:16:41 +07:00

removed almost all node sagas

This commit is contained in:
Fedor Katurov 2022-01-02 20:44:41 +07:00
parent f76a5a4798
commit 168ba8cc04
30 changed files with 268 additions and 448 deletions

View file

@ -21,9 +21,9 @@ interface IProps {
}
const NodeBottomBlock: FC<IProps> = ({ commentsOrder }) => {
const { is_user: isUser } = useUserContext();
const user = useUserContext();
const { node, isLoading } = useNodeContext();
const { comments, isLoading: isLoadingComments } = useCommentContext();
const { comments, isLoading: isLoadingComments, onSaveComment } = useCommentContext();
const { related, isLoading: isLoadingRelated } = useNodeRelatedContext();
const { inline } = useNodeBlocks(node, isLoading);
@ -44,7 +44,9 @@ const NodeBottomBlock: FC<IProps> = ({ commentsOrder }) => {
<NodeComments order={commentsOrder} />
)}
{isUser && !isLoading && <NodeCommentForm nodeId={node.id} />}
{user.is_user && !isLoading && (
<NodeCommentForm nodeId={node.id} saveComment={onSaveComment} user={user} />
)}
</Group>
<div className={styles.panel}>

View file

@ -21,27 +21,24 @@ const NodeComments: FC<IProps> = memo(({ order }) => {
const {
comments,
count,
hasMore,
lastSeenCurrent,
onLoadMoreComments,
onDeleteComment,
onShowImageModal,
onSaveComment,
} = useCommentContext();
const left = useMemo(() => Math.max(0, count - comments.length), [comments, count]);
const groupped: ICommentGroup[] = useGrouppedComments(comments, order, lastSeenCurrent);
const more = useMemo(
() =>
left > 0 && (
hasMore && (
<div className={styles.more} onClick={onLoadMoreComments}>
Показать ещё{' '}
{plural(Math.min(left, COMMENTS_DISPLAY), 'комментарий', 'комментария', 'комментариев')}
{left > COMMENTS_DISPLAY ? ` из ${left} оставшихся` : ''}
Показать ещё комментарии
</div>
),
[left, onLoadMoreComments]
[hasMore, onLoadMoreComments]
);
if (!node?.id) {
@ -61,6 +58,7 @@ const NodeComments: FC<IProps> = memo(({ order }) => {
onDelete={onDeleteComment}
onShowImageModal={onShowImageModal}
isSame={group.user.id === user.id}
saveComment={onSaveComment}
/>
))}