mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
made boris use context
This commit is contained in:
parent
716e58bc15
commit
312156bdf8
5 changed files with 131 additions and 96 deletions
49
src/pages/boris.tsx
Normal file
49
src/pages/boris.tsx
Normal file
|
@ -0,0 +1,49 @@
|
|||
import React, { useEffect, VFC } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
||||
import { selectNode } from '~/redux/node/selectors';
|
||||
import { BorisLayout } from '~/layouts/BorisLayout';
|
||||
import { nodeLoadNode } from '~/redux/node/actions';
|
||||
import { CommentProvider } from '~/utils/providers/CommentProvider';
|
||||
import { useImageModal } from '~/utils/hooks/useImageModal';
|
||||
import { useNodeComments } from '~/utils/hooks/node/useNodeComments';
|
||||
import { useBoris } from '~/utils/hooks/boris/useBoris';
|
||||
|
||||
const BorisPage: VFC = () => {
|
||||
const dispatch = useDispatch();
|
||||
const node = useShallowSelect(selectNode);
|
||||
const {
|
||||
comments,
|
||||
comment_count: count,
|
||||
is_loading_comments: isLoadingComments,
|
||||
} = useShallowSelect(selectNode);
|
||||
|
||||
const onShowImageModal = useImageModal();
|
||||
const { onLoadMoreComments, onDelete: onDeleteComment } = useNodeComments(696);
|
||||
const { title, setIsBetaTester, isTester, stats } = useBoris(comments);
|
||||
|
||||
useEffect(() => {
|
||||
if (node.is_loading) return;
|
||||
dispatch(nodeLoadNode(696, 'DESC'));
|
||||
}, [dispatch]);
|
||||
|
||||
return (
|
||||
<CommentProvider
|
||||
comments={comments}
|
||||
count={count}
|
||||
isLoading={isLoadingComments}
|
||||
onShowImageModal={onShowImageModal}
|
||||
onLoadMoreComments={onLoadMoreComments}
|
||||
onDeleteComment={onDeleteComment}
|
||||
>
|
||||
<BorisLayout
|
||||
title={title}
|
||||
setIsBetaTester={setIsBetaTester}
|
||||
isTester={isTester}
|
||||
stats={stats}
|
||||
/>
|
||||
</CommentProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default BorisPage;
|
Loading…
Add table
Add a link
Reference in a new issue