浏览代码

added text when data empty

makstravm 2 年之前
父节点
当前提交
1b941bcbab

+ 0 - 1
src/components/main/postsFeed/FieldComment.jsx

@@ -17,7 +17,6 @@ const FieldCommentSend = ({ id, sentComment, autoFocus, value = '', setOpen, row
     }
     const sendCommentValid = (value) => {
         if (value.trim() !== '') {
-            console.log(id);
             sentComment(id, value.trim())
             setCommentValue('')
         } else {

+ 7 - 3
src/pages/CollectionPage.jsx

@@ -1,13 +1,13 @@
 import { Divider } from 'antd';
 import Title from 'antd/lib/typography/Title';
-import React, { useEffect, useState } from 'react';
+import React, { useEffect } from 'react';
 import { connect } from 'react-redux';
 import { actionFullMyCollectionLoad, actionRemovePostsFeedAC } from '../actions';
 import { CPosts } from '../components/main/Posts';
 import { Container } from './Content';
 import { CPreloader } from './Preloader';
 
-export const CollectionPage = ({ onLoadPosts, postsRemove }) => {
+export const CollectionPage = ({ posts, onLoadPosts, postsRemove }) => {
 
     useEffect(() => {
         onLoadPosts()
@@ -20,7 +20,11 @@ export const CollectionPage = ({ onLoadPosts, postsRemove }) => {
         <Container>
             <CPreloader promiseName='onLoadMyCollections' />
             <Divider><Title level={1}>Collections</Title></Divider>
-            <CPosts />
+            {posts.lenght
+                ? <CPosts />
+                : <Title level={4}>
+                    The collection is empty. Add posts to your collection
+                </Title>}
         </Container>
     )
 }

+ 8 - 2
src/pages/MainPostsFeed.jsx

@@ -13,6 +13,7 @@ import { CPostTitle } from '../components/main/post/PostTitle'
 import { CPreloader } from './Preloader'
 import { CFieldCommentSend } from '../components/main/postsFeed/FieldComment'
 import { PostCommentDate } from '../components/main/post/PostComment'
+import Title from 'antd/lib/typography/Title'
 
 
 export const PostDescription = ({ title, description, date }) =>
@@ -35,7 +36,7 @@ export const PostDescription = ({ title, description, date }) =>
 const CommentPostFeed = ({ comment }) =>
     <div className='CommentPostFeed'>
         <Link to={`/profile/${comment.owner._id}`}>
-            {comment?.owner?.login}
+            {comment?.owner?.nick || comment?.owner?.login}
         </Link>
         <PostCommentDate createdAt={comment.createdAt} />
         <Paragraph ellipsis={{ rows: 1, expandable: true, symbol: 'more' }}>
@@ -109,7 +110,12 @@ const MainPostsFeed = ({ posts, postsFollowing, clearState, following }) => {
     return (
         <Container>
             <CPreloader promiseName='followingPosts' />
-            {Array.isArray(posts) && posts.map(p => <Post key={p._id} postData={p} />)}
+            {Array.isArray(posts) && posts.length
+                ? posts.map(p => <Post key={p._id} postData={p} />)
+                : <Title level={4}>
+                    The tape is empty. Subscribe to users to see them
+                    posts or create your own
+                </Title>}
         </Container>
     )
 }

+ 7 - 3
src/redux/saga/index.js

@@ -389,11 +389,15 @@ function* handlerCollectionWorker({ _id, flag }) {
 function* loadCollectionWorker() {
     const { myData: { collections }, postsFeed } = yield select()
     !Array.isArray(postsFeed?.posts) && (yield put(actionRemovePostsFeedAC()))
-    const [{ posts: newResult }] = yield call(promiseWorker, actionOnLoadMyCollection(collections?._id, postsFeed?.posts?.length))
-    if (newResult) {
-        yield put(actionAddPostsFeedAC(newResult))
+    if (collections?._id) {
+        const [{ posts: newResult }] = yield call(promiseWorker, actionOnLoadMyCollection(collections?._id, postsFeed?.posts?.length))
+        if (newResult) {
+            yield put(actionAddPostsFeedAC(newResult))
+        }
     }
 
+
+
 }
 
 function* handlerCollectionWatcher() {