فهرست منبع

Add scroll to explore posts

LenDoc 2 سال پیش
والد
کامیت
8b354bf7f3

+ 6 - 4
src/App.js

@@ -3,12 +3,13 @@ import { Provider, connect } from 'react-redux'
 import { Router, Route, Redirect, Switch } from 'react-router-dom'
 import createHistory from 'history/createBrowserHistory'
 import React from 'react'
-import { store } from './reducers'
+import { store } from './redux/reducers'
 import { CPageAboutUser } from './components/User'
 import { CPost } from './components/Post'
 import 'antd/dist/antd.css'
-import { actionFullProfilePage } from './actionReducers'
-import { CExplorePosts } from './components/Expore'
+import { actionFullProfilePage } from './redux/thunk'
+import{actionFullAllGetPosts} from './actions'
+import { CExplorePosts } from './components/Explore'
 import { CPostForFeed, Feed } from './components/PostFeed'
 import { CPostEditor } from './components/NewPost'
 import { Header } from './components/Header'
@@ -65,7 +66,8 @@ function App() {
   if (store.getState().auth?.token) {
     console.log('токен', store.getState().auth?.payload?.sub?.id)
     store.dispatch(
-      actionFullProfilePage(store.getState().auth?.payload?.sub?.id),
+      actionFullProfilePage(store.getState().auth?.payload?.sub?.id)
+   
     )
   } else {
     history.push('/input')

+ 2 - 0
src/App.scss

@@ -228,6 +228,8 @@ main {
 .PostsFeed {
   margin: 20px;
   padding: 40px;
+  // overflow-y: scroll;
+
 }
 .SpoilerButton {
   right: 30px;

+ 0 - 188
src/actionReducers/index.js

@@ -1,188 +0,0 @@
-import {
-  actionAboutMe,
-  actionAllPostsUser,
-  actionAboutUser,
-  actionPostsFeed,
-  actionPostsFeedCount,
-  actionOnePost,
-  actionAddComment,
-  actionAddLike,
-  actionDeleteLike,
-  actionPostsCount,
-  actionAuthLogout,
-  actionClearPromiseForName
-} from '../actions'
-import { history } from '../App'
-//user
-export const actionFullProfilePageUser = (_id) => async (dispatch) => {
-    const aboutUser = await dispatch(actionAboutUser(_id))
-    const allPosts = await dispatch(actionAllPostsUser(_id))
-    await dispatch(actionPostsCount(_id))
-    if (aboutUser && allPosts) {
-      await dispatch(actionProfilePageDataTypeUser(aboutUser, allPosts))
-    }
-  }
-  export const actionClearDataUserType = () => ({ type: 'CLEAR-DATA' })
-  
-  export const actionClearUserData = () => async (dispatch) => {
-    const logOut = await dispatch(actionAuthLogout())
-    if (logOut) {
-      history.push('/input')
-       await dispatch(actionClearDataUserType())
-    }
-  }
-//type
-export const actionProfilePageDataTypeUser = (aboutUser, allPosts) => ({
-    type: 'PROFILE-PAGE-USER',
-    aboutUser,
-    allPosts,
-  })
-  
-  export const actionProfilePageData = (id) => 
-  ({ type: 'DATA_PROFILE', id })
-  
-  //aboutMe
-  
-export const actionFullProfilePage = (_id) => async (dispatch) => {
-    const aboutMe = await dispatch(actionAboutMe(_id))
-    if (aboutMe) {
-      await dispatch(actionProfilePageDataType(aboutMe))
-    }
-  }
-  //type
-  export const actionProfilePageDataType = (aboutMe) => ({
-    type: 'PROFILE-PAGE',
-    aboutMe,
-  })
-  
-  export const actionAvatarUpdate = (aboutUser) => ({
-    type: 'CHANGE-AVATAR-USER',
-    aboutUser,
-  })
-
-export const actionRemoveDataUser = () => 
-({ type: 'REMOVE-DATA' })
-
-//feed
-//type
-export const actionFeedType = (newPosts,newPostsFeedCount) => 
-  ({ type: 'ADD-POSTS', newPosts,newPostsFeedCount })
-  export const actionFeedTypeCount = (postsFeedCount) => 
-  ({ type: 'COUNT', postsFeedCount })
-
-// export const actionFeedTypeStop = (postsFeed) => 
-// ({ type: 'POSTS', postsFeed })
-
-
-export const actionFullFeed = (myFollowing, myId,skip=0) => async (dispatch) => {
-
-
-  // const postsFeed = await dispatch(actionPostsFeed([...myFollowing, myId], skip))
-  const postsFeedCount = await dispatch(actionPostsFeedCount([...myFollowing || [], myId]))
-
-    const newPosts = await dispatch(actionPostsFeed([...myFollowing || [], myId], skip))
-    if (newPosts&&postsFeedCount) {
-      await dispatch(actionFeedType(...newPosts))
-      await dispatch(actionFeedTypeCount(postsFeedCount))
-      // await dispatch(actionClearPromiseForName('postsFeed'))
-    }
-  
-}
-
-// export const actionFullFeed = (myFollowing) => async (dispatch) => {
-
-//     const postsFeed = await dispatch(actionPostsFeed(myFollowing))
-//     console.log('posts feed ', postsFeed)
-//     const skip = postsFeed.length
-    
-//     const postsFeedCount = await dispatch(actionPostsFeedCount(myFollowing))
-//     if (skip < postsFeedCount) {
-//       const newPosts = await dispatch(actionPostsFeed(myFollowing, skip))
-//       if (newPosts) {
-//         await dispatch(actionFeedType(newPosts))
-//       }
-//     }
-//   }
-
-
-//comment
-export const actionAddFullCommentFeed = (postId, newResult) => async (
-    dispatch,
-    getState,
-  ) => {
-    await dispatch(actionAddComment(postId, newResult))
-    const {
-      promise: {
-        addComment: { status },
-      },
-    } = getState()
-    if (status === 'FULFILLED') {
-      const onePost = await dispatch(actionOnePost(postId))
-      if (onePost) await dispatch(actionAddCommentPostInTape(postId, newResult))
-    }
-    // await dispatch(actionOnePost(postId));
-  }
-//type
-export const actionAddCommentPostInTape = (postId, newResult) => ({
-    type: 'ADD-COMMENT-POSTS',
-    postId,
-    newResult,
-  })
-
-//like
-
-
- export const actionAddFullLikeFeed = (postId) => async (dispatch, getState) => {
-    await dispatch(actionAddLike(postId))
-    const {
-      promise: {
-        addLike: { status },
-      },
-    } = getState()
-    if (status === 'FULFILLED') {
-      const onePost = await dispatch(actionOnePost(postId))
-      if (onePost) await dispatch(actionAddLikePostInTape(postId))
-    }
-  }
-export const actionDeleteFullLikeFeed = (likeId, postId) => async (
-    dispatch,
-    getState,
-  ) => {
-    await dispatch(actionDeleteLike(likeId, postId))
-    const {
-      promise: {
-        deleteLike: { status },
-      },
-    } = getState()
-    if (status === 'FULFILLED') {
-      const onePost = await dispatch(actionOnePost(postId))
-      if (onePost) await dispatch(actionDeleteLikePostInTape(likeId, postId))
-    }
-  }
-//type
-const actionAddLikePostInTape = (postId) =>
- ({ type: 'ADD-LIKE-POSTS', postId })
-
- const actionDeleteLikePostInTape = (likeId, postId) => ({
-    type: 'DELETE-LIKE-POSTS',
-    likeId,
-    postId,
-  })
-
-  //one post
-  export const actionFullOnePost = (_id) => async (dispatch) => {
-    const onePost = await dispatch(actionOnePost(_id))
-    if (onePost) {
-      await dispatch(actionOnePostType(onePost))
-      // await dispatch(actionClearDataUserType())
-    }
-  
-  }
-  export const actionFullClearFeedPosts = () => (dispatch) => {
-    return dispatch(actionClearFeedPosts())
-  }
-  //type
-  export const actionOnePostType = (onePost) => ({ type: 'ONE-POST', onePost })
-  export const actionClearPostsOne = () => ({ type: 'CLEAR-POST-ONE' })
-
-export const actionClearFeedPosts = () => ({ type: 'CLEAR-POSTS' })

+ 144 - 202
src/actions/index.js

@@ -2,10 +2,15 @@ import { ConsoleSqlOutlined } from '@ant-design/icons'
 import {
   actionFullProfilePageUser,
   actionFullProfilePage,
-  actionFeedType,
-  actionClearFeedPosts,
-  actionFullFeed,actionFeedTypeStop, actionFeedTypeCount
-} from '../actionReducers'
+
+} from '../redux/thunk'
+import { actionFeedTypeCount } from '../redux/reducers/feed/feedReducer'
+import { actionFeedType } from '../redux/reducers/feed/feedReducer'
+import { actionExploreTypeCount } from '../redux/reducers/explore/exploreReducer'
+import { actionClearExplorePosts } from '../redux/reducers/explore/exploreReducer'
+import { actionExploreType } from '../redux/reducers/explore/exploreReducer'
+import { actionClearFeedPosts } from '../redux/reducers/feed/feedReducer'
+
 import { history } from '../App'
 export const actionAuthLogin = (token) => ({ type: 'AUTH_LOGIN', token })
 export const actionAuthLogout = () => ({ type: 'AUTH_LOGOUT' })
@@ -125,11 +130,13 @@ export const uploadFile = (file) => {
 export const actionUploadFile = (file) =>
   actionPromise('uploadFile', uploadFile(file))
 
-  export const actionClearPromise = (name) => (dispatch) => {
-    return dispatch(actionClearPromiseForName(name));
-};
-export const actionClearPromiseForName = (name) =>
-  ({ type: 'PROMISE_CLEAR', name });
+export const actionClearPromise = (name) => (dispatch) => {
+  return dispatch(actionClearPromiseForName(name))
+}
+export const actionClearPromiseForName = (name) => ({
+  type: 'PROMISE_CLEAR',
+  name,
+})
 
 export const actionUploadFiles = (files) =>
   actionPromise(
@@ -170,7 +177,9 @@ mutation PostUpsert($post:PostInput){
           },
         },
       ),
-    ))}
+    ),
+  )
+}
 
 export const actionAllPosts = (userId) =>
   actionPromise(
@@ -208,42 +217,42 @@ export const actionPostsCount = (_id) =>
     ),
   )
 
-export const actionAllPostsFeed = () =>
-  actionPromise(
-    'postsAllFeed',
-    gql(
-      ` query allPosts($_id:String){
-                PostFind(query:$_id){
-                  owner{_id login avatar{_id url}}
-                   _id title text images{_id url}
-                   likes{
-                    _id
-                    owner{				
-                       _id login avatar {_id url}
-                      }
-                }
-                comments{
-                  _id, createdAt, text  owner{_id login avatar{_id url}}
-                  answers{
-                    _id, createdAt, text owner{_id login  avatar{_id url}}
-                   
-                  }
+// export const actionAllPostsFeed = () =>
+//   actionPromise(
+//     'postsAllFeed',
+//     gql(
+//       ` query allPosts($_id:String){
+//                 PostFind(query:$_id){
+//                   owner{_id login avatar{_id url}}
+//                    _id title text images{_id url}
+//                    likes{
+//                     _id
+//                     owner{
+//                        _id login avatar {_id url}
+//                       }
+//                 }
+//                 comments{
+//                   _id, createdAt, text  owner{_id login avatar{_id url}}
+//                   answers{
+//                     _id, createdAt, text owner{_id login  avatar{_id url}}
 
-                }
-              }
-            }`,
-      {
-        _id: JSON.stringify([
-          {},
-          {
-            sort: [{ _id: -1 }],
-            skip: [0],
-            limit: [10],
-          },
-        ]),
-      },
-    ),
-  )
+//                   }
+
+//                 }
+//               }
+//             }`,
+//       {
+//         _id: JSON.stringify([
+//           {},
+//           {
+//             sort: [{ _id: -1 }],
+//             skip: [0],
+//             limit: [10],
+//           },
+//         ]),
+//       },
+//     ),
+//   )
 
 export const actionOnePost = (_id) =>
   actionPromise(
@@ -441,24 +450,24 @@ export const actionAddSubFullComment = (postId, commentId, comment) => async (
 //             }))
 
 export const actionAddLike = (postId) =>
-    actionPromise(
-      'addLike',
-      gql(
-        `mutation AddLike($like:LikeInput){
+  actionPromise(
+    'addLike',
+    gql(
+      `mutation AddLike($like:LikeInput){
           LikeUpsert(like:$like)
           {
             _id owner{_id login}
           }
         }`,
-        {
-          like: {
-            post: {
-              _id: postId,
-            },
+      {
+        like: {
+          post: {
+            _id: postId,
           },
         },
-      ),
-    )
+      },
+    ),
+  )
 
 export const actionGetFindLiked = (_id) => async (dispatch) => {
   await dispatch(
@@ -503,10 +512,10 @@ export const actionDeleteFullLike = (likeId, postId) => async (
   //  await dispatch(actionOnePost(postId));
 }
 export const actionDeleteLike = (likeId, postId) =>
-    actionPromise(
-      'deleteLike',
-      gql(
-        `mutation DeleteLike($like:LikeInput){
+  actionPromise(
+    'deleteLike',
+    gql(
+      `mutation DeleteLike($like:LikeInput){
           LikeDelete(like: $like)
           {
             _id, post{
@@ -514,16 +523,16 @@ export const actionDeleteLike = (likeId, postId) =>
             }
           }
         }`,
-        {
-          like: {
-            _id: likeId,
-            post: {
-              _id: postId,
-            },
+      {
+        like: {
+          _id: likeId,
+          post: {
+            _id: postId,
           },
         },
-      ),
-    )
+      },
+    ),
+  )
 
 export const actionSetAvatar = (file, myId) => async (dispatch) => {
   const avatar = await dispatch(actionAvatar(file, myId))
@@ -532,9 +541,7 @@ export const actionSetAvatar = (file, myId) => async (dispatch) => {
     await dispatch(actionFullProfilePage(myId))
     await dispatch(actionClearPromise('setAvatar'))
     await dispatch(actionClearPromise('uploadFile'))
-
   }
-
 }
 
 export const actionPostsFeed = (myFollowing, skip) =>
@@ -546,7 +553,6 @@ export const actionPostsFeed = (myFollowing, skip) =>
           owner{_id login avatar{url}}
           images{_id url} title text
           _id likesCount 
-
             likes{
                   _id
                   owner{				
@@ -579,140 +585,65 @@ export const actionPostsFeed = (myFollowing, skip) =>
     ),
   )
 
-// export const actionFullAllGetPosts = () => async (dispatch, getState) => {
-//   const {
-//     feed: { postsFeed = [] },
-//   } = getState()
-//   const myFollowing = getState().promise.aboutMe?.payload?.following?.map(
-//     ({ _id }) => _id,
-//   )
-//   const myId = getState().profileData?.aboutMe?._id
-//   console.log('my following ', myFollowing)
- 
-// console.log('getstate', getState())
-//   // let newPosts = await dispatch(
-//   //   actionPostsFeed([...myFollowing, myId], postsFeed?.length),
-//   // )
- 
-//   const postsFeedCount = await dispatch(actionPostsFeedCount([...myFollowing, myId]))
- 
-//   const skip = postsFeed.length
-// // await dispatch(actionPostsFeed([...myFollowing, myId]))
-//   console.log('скип', skip)
-//   // if (newPosts) {
-//   //   dispatch(actionFeedType(newPosts))
-//   // }
-//   let postsUsers = await dispatch(
-//     actionPostsFeed([...myFollowing, myId], postsFeed?.length),
-//   )
-//   if (skip < postsFeedCount && postsUsers) {
-//     let newPosts = await dispatch(
-//       actionPostsFeed([...myFollowing, myId], skip))
-//     if (newPosts) {
-//       console.log('newPosts ', newPosts)
-//       await dispatch(actionFeedType(newPosts))
-//     }
-//   }
-// }
-
 export const actionFullAllGetPosts = () => async (dispatch, getState) => {
   const {
-    feed: {postsFeed,
-      postsFeedCount
-    },
-    profileData: {
-      aboutMe
-    },
-    promise
+    feed: { postsFeed, postsFeedCount },
+    profileData: { aboutMe },
+    promise,
   } = getState()
-  const myFollowing =aboutMe?.following&& aboutMe?.following?.map(
-    ({ _id }) => _id,
-  )
+  const myFollowing =
+    aboutMe?.following && aboutMe?.following?.map(({ _id }) => _id)
   console.log('myFollowing ', myFollowing)
   const myId = aboutMe?._id
-  console.log('myId ', myId)
-  
   const skip = postsFeed?.length
   // console.log('skip ', skip)
   console.log('postsFeed', postsFeed)
-  // if(postsFeed?.status=='PENDING')
-  // await dispatch(actionClearPromiseForName('postsFeed'))
-  
-  if (skip !==(postsFeedCount ? postsFeedCount:1)) {
-      
-    // const newPostsFeedCount = await dispatch(actionPostsFeedCount([...myFollowing || [], myId]))
-   
-    // if(postsFeed) 
-    const newPosts = await dispatch(actionPostsFeed([...myFollowing || [], myId],skip))
-  console.log('newPosts', newPosts)
-   
-    const newPostsFeedCount = await dispatch(actionPostsFeedCount([...myFollowing || [], myId]))
- 
-   if(newPosts&&newPostsFeedCount)
-{
-  console.log('newPosts', newPosts)
+  if (skip !== (postsFeedCount ? postsFeedCount : 1)) {
+    const newPosts = await dispatch(
+      actionPostsFeed([...(myFollowing || []), myId], skip),
+    )
+    console.log('newPosts', newPosts)
+    const newPostsFeedCount = await dispatch(
+      actionPostsFeedCount([...(myFollowing || []), myId]),
+    )
+    if (newPosts && newPostsFeedCount) {
+      console.log('newPosts', newPosts)
+      await dispatch(actionFeedType(newPosts, newPostsFeedCount))
+      // if(promise?.postsFeed?.status=='PENDING')
+      // await dispatch(actionClearFeedPosts())
+      // await dispatch(actionClearPromiseForName('postsFeed'))
 
-      await dispatch(actionFeedType(newPosts,newPostsFeedCount))
-      if(promise?.postsFeed?.status=='PENDING')
-      await dispatch(actionClearFeedPosts())
-       // await dispatch(actionClearPromiseForName('postsFeed'))
-      
       // await dispatch(actionFeedTypeCount(postsFeedCount))
       // await dispatch(actionClearPromiseForName('postsFeed'))
-   
-    // await dispatch(actionFeedType(newPosts))
+
+      // await dispatch(actionFeedType(newPosts))
+    }
   }
+}
 
-  console.log('newPosts', newPosts)
+export const actionFullExplorePosts = () => async (dispatch, getState) => {
+  const {
+    explore: { explorePosts, explorePostsCount },
+    promise,
+  } = getState()
+  console.log('explorePosts', explorePosts)
 
-    // if (newPosts) {
-    //   // await dispatch(actionFeedTypeCount(newPostsFeedCount))
-    //   await dispatch(actionFeedType(newPosts))
-     
-    
-    }
+  if (explorePosts?.length !== (explorePostsCount ? explorePostsCount : 1)) {
+    console.log('explorePosts', explorePosts)
+
+    const newPosts = await dispatch(actionExplorePosts(explorePosts?.length))
+
+    console.log('newPosts', newPosts)
+
+    const newPostsExploreCount = await dispatch(actionExplorePostsCount())
+    if (newPostsExploreCount && newPosts)
+      await dispatch(actionExploreType(newPosts, newPostsExploreCount))
+
+    // if (promise?.explorePosts?.status == 'PENDING')
+    //   await dispatch(actionClearExplorePosts())
+  }
 }
-  // }
-// }
 
-// export const actionFullAllGetPosts = () => async (dispatch, getState) => {
-   
-//   // const {
-//   //     feed: { postsFeed = [] },
-//   //   } = getState() 
-//   const myFollowing = getState().promise.aboutMe?.payload?.following?.map(
-//       ({ _id }) => _id,
-//   )
-//   const myId = getState().profileData?.aboutMe?._id
-//     const postsFeed = await dispatch(actionPostsFeed([...myFollowing,myId]))
-//     console.log('posts feed ', postsFeed)
-//   const skip = postsFeed.length
-//   console.log('skip', skip)
-//    if(postsFeed>=skip)
-//   await dispatch(actionFeedType(postsFeed))
- 
-//   const postsFeedCount = await dispatch(actionPostsFeedCount([...myFollowing,myId]))
-//   if (skip < postsFeedCount) {
-//     const newPosts = await dispatch(actionPostsFeed([...myFollowing,myId], skip))
-//    console.log('new posts ', newPosts)
-//     if (newPosts) {
-//       await dispatch(actionFeedType(newPosts))
-//     }
-//   }
-   // await dispatch(actionFullFeed([...myFollowing, myId]))
-   
-    // console.log('my following ', myFollowing)
-    
-    
-    // let postsUsers = await dispatch(
-    //   actionFullFeed(...myFollowing),
-    // )
-    // console.log('postsUsers ', postsUsers)
-  
-    // if (postsUsers) {
-    //   dispatch(actionFeedType(postsUsers))
-    // }
- // }
 export const actionPostsFeedCount = (myFollowing) =>
   actionPromise(
     'postsFeedCount',
@@ -726,7 +657,7 @@ export const actionPostsFeedCount = (myFollowing) =>
         _id: JSON.stringify([
           {
             ___owner: {
-              $in: myFollowing
+              $in: myFollowing,
             },
           },
         ]),
@@ -738,8 +669,8 @@ export const actionExplorePosts = (skip) =>
   actionPromise(
     'explorePosts',
     gql(
-      ` query PostsFeed($id:String){
-        PostFind(query:$id){
+      ` query PostsFeed($_id:String){
+        PostFind(query:$_id){
         owner{_id login avatar{url}}
         images{_id url} title text
         _id likesCount 
@@ -760,18 +691,31 @@ export const actionExplorePosts = (skip) =>
 }
             }`,
       {
-        id: JSON.stringify([
+        _id: JSON.stringify([
           {},
           {
             sort: [{ _id: -1 }],
             skip: [skip || 0],
-            limit: [300],
+            limit: [10],
           },
         ]),
       },
     ),
   )
+export const actionExplorePostsCount = () =>
+  actionPromise(
+    'explorePostsCount',
+    gql(
+      ` query CountAllPosts($_id:String!){
+                PostCount(query:$_id)
+
+                }`,
 
+      {
+        _id: JSON.stringify([{}]),
+      },
+    ),
+  )
 export const actionSearchUser = (userName) => async (dispatch) => {
   await dispatch(
     actionPromise(
@@ -798,7 +742,7 @@ export const actionSearchUser = (userName) => async (dispatch) => {
   )
 }
 
-export const actionUserUpsert = (user,myId) =>
+export const actionUserUpsert = (user, myId) =>
   actionPromise(
     'userUpsert',
     gql(
@@ -810,13 +754,13 @@ export const actionUserUpsert = (user,myId) =>
       {
         user: {
           _id: myId,
-          ...user
-        }
+          ...user,
+        },
       },
     ),
   )
 
-  // export con
+// export con
 export const actionAboutUser = (_id) =>
   actionPromise(
     'aboutUser',
@@ -913,8 +857,8 @@ export const actionFullSubscribe = (my_Id, followId) => async (
   )
   if (followingId) {
     Promise.all([
-      dispatch(actionFullProfilePageUser(followId)),
-      dispatch(actionFullProfilePage(my_Id)),
+      await dispatch(actionFullProfilePageUser(followId)),
+      await dispatch(actionFullProfilePage(my_Id)),
     ])
     await dispatch(actionClearFeedPosts())
   }
@@ -992,8 +936,6 @@ export const actionUserUpdate = (user, myId) => async (dispatch, getState) => {
   if (status === 'FULFILLED') {
     await dispatch(actionFullProfilePage(myId))
     await dispatch(actionFullProfilePageUser(myId))
-    
-
   }
 }
 

+ 82 - 0
src/components/Explore.js

@@ -0,0 +1,82 @@
+import {
+  actionOnePost, actionExplorePosts,
+  actionFullExplorePosts
+} from '../actions'
+import { Row, Col } from 'antd'
+import { Card } from './Post'
+import React, { useEffect,useState } from 'react'
+import { connect } from 'react-redux'
+import {
+  actionClearExplorePosts,
+  actionAllClearExplore
+} from '../redux/reducers/explore/exploreReducer'
+  
+const ExplorePosts = ({ explorePosts = [], onPost, onClearExplore,
+  onExlorePosts,explorePostsCount }) => {
+  const [checkScroll, setScroll] = useState(true)
+  console.log('scroll ', checkScroll)
+  useEffect(() =>
+  {
+    if (checkScroll) {
+    onExlorePosts()
+    
+    setScroll(false)
+    }
+  }, [checkScroll])
+
+  useEffect(() => {
+    
+    document.addEventListener('scroll', scrollHandler)
+
+    return () => {
+      document.removeEventListener('scroll', scrollHandler)
+    onClearExplore()
+    }
+  }, [])
+
+  const scrollHandler = (e) => {
+    if (e.target.documentElement.scrollHeight - (e.target.documentElement.scrollTop + window.innerHeight) < 200) {
+      setScroll(true)
+      
+    }
+  }
+
+    // useEffect(() => {
+    //     onExlorePosts()
+       
+    //   }, [])
+    return (
+    <>
+      <Row>
+            <Col span={18} offset={4}>
+            <div
+            style={{
+              display: 'flex',
+              flexWrap: 'wrap',
+              padding: '20px',
+              margin: '20px',
+            }}
+          >
+            {(explorePosts || [])?.map((item) => (
+              <Card post={item} onPost={onPost} />
+            ))}
+          </div> 
+                
+        </Col>
+            </Row>
+        </>
+    )
+}
+export const CExplorePosts = connect(
+    (state) => ({
+      my_Id: state.auth?.payload?.sub?.id || '',
+      countAllPostsUser: state.promise?.countAllPostsUser?.payload,
+    explorePosts: state.explore?.explorePosts,
+    explorePostsCount:state.explore?.explorePostsCount,
+    }),
+  {
+    onExlorePosts: actionFullExplorePosts,
+      onPost: actionOnePost,
+      onClearExplore:actionClearExplorePosts
+    },
+  )(ExplorePosts)

+ 0 - 45
src/components/Expore.js

@@ -1,45 +0,0 @@
-import {
-    actionOnePost, actionExplorePosts
-} from '../actions'
-import { Row, Col } from 'antd'
-import { Card } from './Post'
-import React, { useEffect } from 'react'
-import { connect } from 'react-redux'
-  
-const ExplorePosts = ({explorePosts,onPost,onExlorePosts }) => {
-    useEffect(() => {
-        onExlorePosts()
-       
-      }, [])
-    return (
-    <>
-      <Row>
-            <Col span={15} offset={6}>
-            <div
-            style={{
-              display: 'flex',
-              flexWrap: 'wrap',
-              padding: '20px',
-              margin: '20px',
-            }}
-          >
-            {(explorePosts || [])?.map((item) => (
-              <Card post={item} onPost={onPost} />
-            ))}
-          </div> 
-                
-        </Col>
-            </Row>
-        </>
-    )
-}
-export const CExplorePosts = connect(
-    (state) => ({
-      my_Id: state.auth?.payload?.sub?.id || '',
-      countAllPostsUser: state.promise?.countAllPostsUser?.payload,
-      explorePosts: state.promise?.explorePosts?.payload
-    }),
-    {onExlorePosts: actionExplorePosts,
-      onPost: actionOnePost
-    },
-  )(ExplorePosts)

+ 1 - 1
src/components/Header.js

@@ -1,5 +1,5 @@
 import user from '../materials/user.png'
-import { actionFullProfilePageUser } from '../actionReducers'
+import { actionFullProfilePageUser } from '../redux/thunk'
 import { Avatar, Button } from 'antd'
 import { CSearch } from './Search_Users'
 import { Link } from 'react-router-dom'

+ 1 - 1
src/components/LoginRegisterLogout.js

@@ -4,7 +4,7 @@ import React, { useState } from 'react'
 import { connect } from 'react-redux'
 import { Button, Input, Checkbox, Form } from 'antd'
 import { Link } from 'react-router-dom'
-import { actionClearUserData } from '../actionReducers'
+import { actionClearUserData } from '../redux/thunk'
 import { message } from 'antd'
 import { useEffect } from 'react'
 

+ 1 - 1
src/components/NewPost.js

@@ -5,7 +5,7 @@ import {
   actionUploadFiles,
   actionPostUpsert
 } from '../actions'
-import { actionClearPostsOne } from '../actionReducers'
+import { actionClearPostsOne } from '../redux/reducers/post/postReducer'
 import { Button, message } from 'antd'
 import {
   Basic,

+ 3 - 4
src/components/Post.js

@@ -13,17 +13,16 @@ import { connect } from 'react-redux'
 import { Row, Col } from 'antd'
 import { CComments, AddComment } from '../components/Post_Comment'
 import { CPostEditor } from '../components/NewPost'
-import { actionFullOnePost } from '../actionReducers'
+import { actionFullOnePost } from '../redux/reducers/post/postReducer'
 import { Like, Likes } from './Like'
 import { ConstructorModal } from '../helpers'
 import React, { useState, useEffect } from 'react'
 import {
-  actionFullFeed,
-  actionClearFeedPosts,
+
   actionAddFullCommentFeed,
   actionAddFullLikeFeed,
   actionDeleteFullLikeFeed,
-} from '../actionReducers'
+} from '../redux/thunk'
 import {LinkToUser} from './LinkToUser'
 const EditMyPost = ({ _id }) => {
   return (

+ 8 - 7
src/components/PostFeed.js

@@ -18,8 +18,9 @@ import {
   actionAddFullCommentFeed,
   actionAddFullLikeFeed,
   actionDeleteFullLikeFeed,
-} from '../actionReducers'
-
+ 
+} from '../redux/thunk'
+import {actionFullClearFeedPosts} from '../redux/reducers/feed/feedReducer'
 import { Link } from 'react-router-dom'
 import { Provider, connect } from 'react-redux'
 import { Upload, Button, DatePicker, Space } from 'antd'
@@ -45,11 +46,10 @@ const MyPostFeed = ({
       setScroll(false)
     }
   }, [checkScroll])
-
+  console.log('check scroll ', checkScroll)
   useEffect(() => {
     
     document.addEventListener('scroll', scrollHandler)
-
     return () => {
       document.removeEventListener('scroll', scrollHandler)
     onClearFeed()
@@ -57,7 +57,8 @@ const MyPostFeed = ({
   }, [])
 
   const scrollHandler = (e) => {
-    if (e.target.documentElement.scrollHeight - (e.target.documentElement.scrollTop + window.innerHeight) < 200) {
+    if (e.target.documentElement.scrollHeight -
+      (e.target.documentElement.scrollTop + window.innerHeight) < 200) {
       setScroll(true)
       
     }
@@ -83,7 +84,7 @@ const MyPostFeed = ({
               )}
               {(postsFeed || []).map(
                 ({ _id, images, title, text, owner, comments, likes }) => (
-                  <div className="PostFeed" key={_id}>
+                  <div className="PostFeed" >
                     <LinkToUser owner={owner} size="70px" />
                     <MyCarousel images={images} style={{ marginTop: '60px' }} />
                     <h1 className='Title'> Title: {title || ''}</h1>
@@ -134,7 +135,7 @@ export const CPostForFeed = connect(
   }),
   {
     onPostsFeed: actionFullAllGetPosts,
-    onClearFeed: actionClearFeedPosts,
+    onClearFeed: actionFullClearFeedPosts,
     addComment: actionAddFullCommentFeed,
     addCommentReply: actionAddSubFullComment,
     addLike: actionAddFullLikeForFeed,

+ 1 - 1
src/components/Search_Users.js

@@ -5,7 +5,7 @@ import user from '../materials/user.png'
 import { actionSearchUser } from '../actions'
 import {UserOutlined } from '@ant-design/icons'
 
-import { actionFullProfilePageUser } from '../actionReducers'
+import { actionFullProfilePageUser } from '../redux/thunk'
 export const ResultUserFind = ({
   userFind = [],
   handleCancel,

+ 3 - 2
src/components/User.js

@@ -14,8 +14,9 @@ import { connect } from 'react-redux'
 import { Avatar, Button} from 'antd'
 import {
   actionFullProfilePageUser,
-  actionRemoveDataUser,
-} from '../actionReducers'
+ 
+} from '../redux/thunk'
+import { actionRemoveDataUser } from '../redux/reducers/profileData/profileReducer'
 import { Row, Col } from 'antd'
 import { CEditInfo } from '../components/EditAvatar'
 

+ 0 - 193
src/reducers/index.js

@@ -1,193 +0,0 @@
-
-import { createStore, combineReducers, applyMiddleware } from 'redux'
-import thunk from 'redux-thunk'
-function promiseReducer(state = {}, { type, name, status, payload, error }) {
- 
-  if (type === 'PROMISE') {
-    return {
-      ...state,
-      [name]: { status, payload, error },
-    }
-  }
-  if (type === 'PROMISE_CLEAR') {
-    return {
-      ...state,
-      [name]: null,
-    }
-  }
-  return state
-}
-
-const jwtDecode = (token) => {
-  try {
-    return JSON.parse(atob(token.split('.')[1]))
-  } catch (e) {
-    return null
-  }
-}
-
-export const profileUserReducer = (
-  state = {},
-  { type, aboutUser, allPosts, newPosts },
-) => {
-  const types = {
-    'PROFILE-PAGE-USER': () => {
-      return {
-        ...state,
-        aboutUser,
-        allPosts,
-      }
-    },
-    'CLEAR-DATA': () => {
-      return {
-        ...(state = {}),
-        aboutUser: {},
-        allPosts: [],
-      }
-    },
-    'CHANGE-AVATAR-USER': () => {
-      return {
-        ...state,
-        aboutUser,
-      }
-    },
-  }
-
-  if (type in types) {
-    return types[type]()
-  }
-  return state
-}
-
-export const feedReducer = (
-  state = {},
-  { skip, type, newPosts = [], postId, postsFeed, postsFeedCount,newPostsFeedCount, newResult },
-) => {
-  const types = {
-    'ADD-POSTS': () => {
-      return {
-        ...state,
-        postsFeed: state?.postsFeed ? [...state.postsFeed, ...newPosts] : [...newPosts],
-        // postsFeed: [...postsFeed || [], ...newPosts],
-        postsFeedCount: postsFeedCount ? postsFeedCount : newPostsFeedCount
-            
-       // postsFeed: postsFeed ? [...postsFeed, ...newPosts] : [...newPosts],
-      }
-    },
-    'COUNT': () => {
-      return {
-        ...state,
-        postsFeedCount: postsFeedCount,
-      }
-    },
-    'POSTS': () => {
-      return {
-        ...state,
-        postsFeed: postsFeed ,
-      }
-    },
-    'CLEAR-POSTS': () => ({
-      ...state,
-      postsFeed: [],
-      postsFeedCount: 0,
-  }),
-
-    'ADD-LIKE-POSTS': () => ({
-      ...state,
-      postsFeed: postsFeed?.map((p) =>
-        p._id === postId ? (p = { ...p, likes: [...newResult] }) : p,
-      ),
-    }),
-    'DELETE-LIKE-POSTS': () => ({
-      ...state,
-      postsFeed: postsFeed?.map((p) =>
-        p._id === postId ? (p = { ...p, likes: [...newResult] }) : p,
-      ),
-    }),
-
-    'ADD-COMMENT-POSTS': () => ({
-      ...state,
-      postsFeed: postsFeed?.map((p) =>
-        p._id === postId ? (p = { ...p, comments: [...newResult] }) : p,
-      ),
-    }),
-  }
-  if (type in types) {
-    return types[type]()
-  }
-  return state
-}
-export const postReducer = (
-  state = {},
-  { skip, type, newPosts = [], onePost, postsFeed, postsFeedCount },
-) => {
-  const types = {
-    'ONE-POST': () => {
-      return {
-        ...state,
-        onePost,
-      }
-    },
-    'CLEAR-POST-ONE': () => {
-      return {
-        ...state,
-        onePost: {},
-      }
-    },
-  }
-  if (type in types) {
-    return types[type]()
-  }
-  return state
-}
-
-export const profileReducer = (state = {}, { type, aboutMe, newResult }) => {
-  const types = {
-    'PROFILE-PAGE': () => {
-      return {
-        ...state,
-        aboutMe,
-      }
-    },
-    'REMOVE-DATA': () => {
-      return {
-        ...(state = {}),
-        aboutMe: {},
-      }
-    },
-  }
-  if (type in types) {
-    return types[type]()
-  }
-  return state
-}
-
-function authReducer(state, { type, token }) {
-  if (state === undefined && localStorage.authToken) {
-    token = localStorage.authToken
-    type = 'AUTH_LOGIN'
-  }
-  if (type === 'AUTH_LOGIN') {
-    if (jwtDecode(token)) {
-      localStorage.authToken = token
-      return { token, payload: jwtDecode(token) }
-    }
-  }
-  if (type === 'AUTH_LOGOUT') {
-    localStorage.authToken = ''
-    return {}
-  }
-  return state || {}
-}
-
-export const store = createStore(
-  combineReducers({
-    promise: promiseReducer,
-    auth: authReducer,
-    profileData: profileReducer,
-    profilePage: profileUserReducer,
-    feed: feedReducer,
-    post: postReducer,
-  }),
-  applyMiddleware(thunk),
-)

+ 26 - 0
src/redux/reducers/auth/authReducer.js

@@ -0,0 +1,26 @@
+export function authReducer(state, { type, token }) {
+    if (state === undefined && localStorage.authToken) {
+      token = localStorage.authToken
+      type = 'AUTH_LOGIN'
+    }
+    if (type === 'AUTH_LOGIN') {
+      if (jwtDecode(token)) {
+        localStorage.authToken = token
+        return { token, payload: jwtDecode(token) }
+      }
+    }
+    if (type === 'AUTH_LOGOUT') {
+      localStorage.authToken = ''
+      return {}
+    }
+    return state || {}
+}
+  
+  const jwtDecode = (token) => {
+    try {
+      return JSON.parse(atob(token.split('.')[1]))
+    } catch (e) {
+      return null
+    }
+  }
+  

+ 51 - 0
src/redux/reducers/explore/exploreReducer.js

@@ -0,0 +1,51 @@
+
+export const exploreReducer = (
+    state = {},
+    { skip, type, newPosts = [],explorePostsCount, postId, explorePosts, postsFeedCount,newPostsExploreCount, newResult },
+  ) => {
+    const types = {
+      'ADD-EXPLORE-POSTS': () => {
+        return {
+          ...state,
+          explorePosts: state?.explorePosts ? [...state.explorePosts, ...newPosts] : [...newPosts],
+          explorePostsCount: explorePostsCount ? explorePostsCount : newPostsExploreCount
+        }
+      },
+      'EXPLORE-COUNT': () => {
+        return {
+          ...state,
+          explorePostsCount: explorePostsCount ? explorePostsCount : newPostsExploreCount,
+        }
+      },
+      'EXPLORE-POSTS': () => {
+        return {
+          ...state,
+          explorePosts: explorePosts ,
+        }
+      },
+      'CLEAR-EXPLORE-POSTS': () => ({
+        ...state,
+        explorePosts: [],
+        explorePostsCount: 0,
+    }),
+    }
+    if (type in types) {
+      return types[type]()
+    }
+    return state
+}
+// export const actionAllClearExplore = () => async (dispatch) => {
+//   Promise.all([
+//     await dispatch(actionClearPromiseForName('explorePosts')),
+//     await dispatch(actionClearPromiseForName('explorePostsCount')),
+//       await dispatch(actionClearExplorePosts())
+//   ])
+
+// }
+export const actionClearExplorePosts = () =>
+  ({ type: 'CLEAR-EXPLORE-POSTS' })
+
+export const actionExploreType = (newPosts,newPostsExploreCount) => 
+  ({ type: 'ADD-EXPLORE-POSTS', newPosts,newPostsExploreCount })
+  export const actionExploreTypeCount = (explorePostsCount) => 
+  ({ type: 'EXPLORE-COUNT', explorePostsCount })

+ 96 - 0
src/redux/reducers/feed/feedReducer.js

@@ -0,0 +1,96 @@
+import { actionClearPromiseForName } from '../../../actions'
+// import { actionClearDataUserType } from '../profileUserPage/profileUserReducer'
+// import { actionProfilePageDataTypeUser } from '../profileUserPage/profileUserReducer'
+
+export const feedReducer = (
+    state = {},
+    { skip, type, newPosts = [], postId, postsFeed, postsFeedCount,newPostsFeedCount, newResult },
+  ) => {
+    const types = {
+      'ADD-POSTS': () => {
+        return {
+          ...state,
+          postsFeed: state?.postsFeed ? [...state.postsFeed, ...newPosts] : [...newPosts],
+          // postsFeed: [...postsFeed || [], ...newPosts],
+          postsFeedCount: postsFeedCount ? postsFeedCount : newPostsFeedCount
+         // postsFeed: postsFeed ? [...postsFeed, ...newPosts] : [...newPosts],
+        }
+      },
+      'COUNT': () => {
+        return {
+          ...state,
+          postsFeedCount: postsFeedCount,
+        }
+      },
+      'POSTS': () => {
+        return {
+          ...state,
+          postsFeed: postsFeed ,
+        }
+      },
+      'CLEAR-POSTS': () => ({
+        ...state,
+        postsFeed: [],
+        postsFeedCount: 0,
+    }),
+  
+      'ADD-LIKE-POSTS': () => ({
+        ...state,
+        postsFeed: postsFeed?.map((p) =>
+          p._id === postId ? (p = { ...p, likes: [...newResult] }) : p,
+        ),
+      }),
+      'DELETE-LIKE-POSTS': () => ({
+        ...state,
+        postsFeed: postsFeed?.map((p) =>
+          p._id === postId ? (p = { ...p, likes: [...newResult] }) : p,
+        ),
+      }),
+  
+      'ADD-COMMENT-POSTS': () => ({
+        ...state,
+        postsFeed: postsFeed?.map((p) =>
+          p._id === postId ? (p = { ...p, comments: [...newResult] }) : p,
+        ),
+      }),
+    }
+    if (type in types) {
+      return types[type]()
+    }
+    return state
+}
+export const actionFullClearFeedPosts = () => (dispatch) => {
+  return dispatch(actionClearFeedPosts())
+}
+export const actionAllClearFeed = () => async (dispatch) => {
+  Promise.all([
+    await dispatch(actionClearPromiseForName('postsFeed')),
+    await dispatch(actionClearPromiseForName('postsFeedCount')),
+      await dispatch(actionClearFeedPosts())
+  ])
+
+}
+export const actionClearFeedPosts = () =>
+  ({ type: 'CLEAR-POSTS' })
+
+//type
+export const actionAddLikePostInTape = (postId) =>
+ ({ type: 'ADD-LIKE-POSTS', postId })
+
+ export const actionDeleteLikePostInTape = (likeId, postId) => ({
+    type: 'DELETE-LIKE-POSTS',
+    likeId,
+    postId,
+  })
+  export const actionAddCommentPostInTape = (postId, newResult) => ({
+    type: 'ADD-COMMENT-POSTS',
+    postId,
+    newResult,
+  })
+
+export const actionFeedType = (newPosts, newPostsFeedCount) => 
+({ type: 'ADD-POSTS', newPosts,newPostsFeedCount })
+export const actionFeedTypeCount = (postsFeedCount) => 
+({ type: 'COUNT', postsFeedCount })
+
+

+ 24 - 0
src/redux/reducers/index.js

@@ -0,0 +1,24 @@
+
+import { createStore, combineReducers, applyMiddleware } from 'redux'
+import thunk from 'redux-thunk'
+import { promiseReducer } from './promise/promiseReducer'
+import { authReducer } from './auth/authReducer'
+import { profileReducer } from './profileData/profileReducer'
+import { profileUserReducer } from './profileUserPage/profileUserReducer'
+import { feedReducer } from './feed/feedReducer'
+import { postReducer } from './post/postReducer'
+import { exploreReducer } from './explore/exploreReducer'
+
+
+export const store = createStore(
+  combineReducers({
+    promise: promiseReducer,
+    auth: authReducer,
+    profileData: profileReducer,
+    profilePage: profileUserReducer,
+    feed: feedReducer,
+    post: postReducer,
+    explore: exploreReducer
+  }),
+  applyMiddleware(thunk),
+)

+ 39 - 0
src/redux/reducers/post/postReducer.js

@@ -0,0 +1,39 @@
+import {actionOnePost} from '../../../actions'
+export const postReducer = (
+    state = {},
+    { skip, type, newPosts = [], onePost, postsFeed, postsFeedCount },
+  ) => {
+    const types = {
+      'ONE-POST': () => {
+        return {
+          ...state,
+          onePost,
+        }
+      },
+      'CLEAR-POST-ONE': () => {
+        return {
+          ...state,
+          onePost: {},
+        }
+      },
+    }
+    if (type in types) {
+      return types[type]()
+    }
+    return state
+  }
+
+
+  //type
+  export const actionOnePostType = (onePost) => ({ type: 'ONE-POST', onePost })
+  export const actionClearPostsOne = () => ({ type: 'CLEAR-POST-ONE' })
+ 
+   //one post
+   export const actionFullOnePost = (_id) => async (dispatch) => {
+    const onePost = await dispatch(actionOnePost(_id))
+    if (onePost) {
+      await dispatch(actionOnePostType(onePost))
+      // await dispatch(actionClearDataUserType())
+    }
+  
+  }

+ 33 - 0
src/redux/reducers/profileData/profileReducer.js

@@ -0,0 +1,33 @@
+
+export const profileReducer = (state = {}, { type, aboutMe, newResult }) => {
+    const types = {
+      'PROFILE-PAGE': () => {
+        return {
+          ...state,
+          aboutMe,
+        }
+      },
+      'REMOVE-DATA': () => {
+        return {
+          ...(state = {}),
+          aboutMe: {},
+        }
+      },
+    }
+    if (type in types) {
+      return types[type]()
+    }
+    return state
+  }
+    //type
+    export const actionProfilePageDataType = (aboutMe) => ({
+      type: 'PROFILE-PAGE',
+      aboutMe,
+    })
+    
+
+  
+  export const actionRemoveDataUser = () => 
+  ({ type: 'REMOVE-DATA' })
+  
+  

+ 54 - 0
src/redux/reducers/profileUserPage/profileUserReducer.js

@@ -0,0 +1,54 @@
+
+export const profileUserReducer = (
+    state = {},
+    { type, aboutUser, allPosts, newPosts },
+  ) => {
+    const types = {
+      'PROFILE-PAGE-USER': () => {
+        return {
+          ...state,
+          aboutUser,
+          allPosts,
+        }
+      },
+      'CLEAR-DATA': () => {
+        return {
+          ...(state = {}),
+          aboutUser: {},
+          allPosts: [],
+        }
+      },
+      'CHANGE-AVATAR-USER': () => {
+        return {
+          ...state,
+          aboutUser,
+        }
+      },
+    }
+  
+    if (type in types) {
+      return types[type]()
+    }
+    return state
+  }
+  
+  export const actionAvatarUpdate = (aboutUser) => ({
+    type: 'CHANGE-AVATAR-USER',
+    aboutUser,
+})
+export const actionProfilePageDataTypeUser = (aboutUser, allPosts) => ({
+  type: 'PROFILE-PAGE-USER',
+  aboutUser,
+  allPosts,
+})
+
+export const actionProfilePageData = (id) => 
+({ type: 'DATA_PROFILE', id })
+
+
+export const actionClearDataUserType = () =>
+  ({ type: 'CLEAR-DATA' })
+  
+
+
+

+ 17 - 0
src/redux/reducers/promise/promiseReducer.js

@@ -0,0 +1,17 @@
+export function promiseReducer(state = {}, { type, name, status, payload, error }) {
+ 
+    if (type === 'PROMISE') {
+      return {
+        ...state,
+        [name]: { status, payload, error },
+      }
+    }
+    if (type === 'PROMISE_CLEAR') {
+      return {
+        ...state,
+        [name]: null,
+      }
+    }
+    return state
+  }
+  

+ 101 - 0
src/redux/thunk/index.js

@@ -0,0 +1,101 @@
+
+import {
+    actionAboutMe,
+    actionAllPostsUser,
+    actionAboutUser,
+    actionPostsFeed,
+    actionPostsFeedCount,
+    actionOnePost,
+    actionAddComment,
+    actionAddLike,
+    actionDeleteLike,
+    actionPostsCount,
+    actionAuthLogout,
+    actionClearPromiseForName
+  } from '../../actions'
+import { history } from '../../App'
+  
+import { actionProfilePageDataType } from '../reducers/profileData/profileReducer'
+import { actionFullAllGetPosts } from '../../actions'
+import { actionAddLikePostInTape } from '../reducers/feed/feedReducer'
+import{actionDeleteLikePostInTape} from '../reducers/feed/feedReducer'
+import{actionAddCommentPostInTape} from '../reducers/feed/feedReducer'
+import{actionProfilePageDataTypeUser} from '../reducers/profileUserPage/profileUserReducer'
+//profile page about me
+export const actionFullProfilePage = (_id) => async (dispatch) => {
+    const aboutMe = await dispatch(actionAboutMe(_id))
+    if (aboutMe) {
+     const data = await dispatch(actionProfilePageDataType(aboutMe))
+      if (data)
+        await dispatch(actionFullAllGetPosts())
+  }
+ 
+  }
+
+export const actionAddFullLikeFeed = (postId) => async (dispatch, getState) => {
+    await dispatch(actionAddLike(postId))
+    const {
+      promise: {
+        addLike: { status },
+      },
+    } = getState()
+    if (status === 'FULFILLED') {
+      const onePost = await dispatch(actionOnePost(postId))
+      if (onePost) await dispatch(actionAddLikePostInTape(postId))
+    }
+}
+  
+export const actionDeleteFullLikeFeed = (likeId, postId) => async (
+    dispatch,
+    getState,
+  ) => {
+    await dispatch(actionDeleteLike(likeId, postId))
+    const {
+      promise: {
+        deleteLike: { status },
+      },
+    } = getState()
+    if (status === 'FULFILLED') {
+      const onePost = await dispatch(actionOnePost(postId))
+      if (onePost) await dispatch(actionDeleteLikePostInTape(likeId, postId))
+    }
+  }
+
+  //comment
+export const actionAddFullCommentFeed = (postId, newResult) => async (
+    dispatch,
+    getState,
+  ) => {
+    await dispatch(actionAddComment(postId, newResult))
+    const {
+      promise: {
+        addComment: { status },
+      },
+    } = getState()
+    if (status === 'FULFILLED') {
+      const onePost = await dispatch(actionOnePost(postId))
+      if (onePost) await dispatch(actionAddCommentPostInTape(postId, newResult))
+    }
+    // await dispatch(actionOnePost(postId));
+}
+
+//clear user data after log out
+export const actionClearUserData = () => async (dispatch) => {
+    const logOut = await dispatch(actionAuthLogout())
+    if (logOut) {
+      history.push('/input')
+       await dispatch(actionClearDataUserType())
+    }
+  }
+
+
+//full profile user
+export const actionFullProfilePageUser = (_id) => async (dispatch) => {
+    const aboutUser = await dispatch(actionAboutUser(_id))
+    const allPosts = await dispatch(actionAllPostsUser(_id))
+    await dispatch(actionPostsCount(_id))
+    if (aboutUser && allPosts) {
+      await dispatch(actionProfilePageDataTypeUser(aboutUser, allPosts))
+  }
+
+  }