From fb370cc5cbb82cd453e1998f7d63419437265d0e Mon Sep 17 00:00:00 2001 From: aymanhki Date: Tue, 9 Apr 2024 15:01:48 -0500 Subject: [PATCH] Bug fixes --- epoch_frontend/src/modules/Feed.js | 6 ++- epoch_frontend/src/modules/Post.js | 49 +++++++++++++++++++- epoch_frontend/src/modules/ProtectedRoute.js | 1 - epoch_frontend/src/pages/Comments.js | 2 +- epoch_frontend/src/pages/Favorites.js | 2 +- epoch_frontend/src/pages/Hashtag.js | 4 +- epoch_frontend/src/pages/home.js | 2 +- epoch_frontend/src/pages/profile.js | 4 +- 8 files changed, 59 insertions(+), 11 deletions(-) diff --git a/epoch_frontend/src/modules/Feed.js b/epoch_frontend/src/modules/Feed.js index f5a4b25..1db0ce6 100644 --- a/epoch_frontend/src/modules/Feed.js +++ b/epoch_frontend/src/modules/Feed.js @@ -29,7 +29,8 @@ export default function Feed({ posts, isInFavorites, isInHashtags, - hashtag + hashtag, + isInComments }) { const [isLoading, setIsLoading] = useState(true); @@ -372,7 +373,8 @@ export default function Feed({ setFileBlob={setFileBlob} setPostToEditId={setPostToEditId} setPostToEditCaption={setPostToEditCaption} - setPostToEdit={setPostToEdit}/> + setPostToEdit={setPostToEdit} + isInComments={isInComments}/> )) )} diff --git a/epoch_frontend/src/modules/Post.js b/epoch_frontend/src/modules/Post.js index c322b9f..0be1a53 100644 --- a/epoch_frontend/src/modules/Post.js +++ b/epoch_frontend/src/modules/Post.js @@ -12,7 +12,7 @@ import {favoritePost, removeFavoritePost, votePost, removeVotePost} from "../ser import ForumOutlinedIcon from '@mui/icons-material/ForumOutlined'; import ShareOutlinedIcon from '@mui/icons-material/ShareOutlined'; -export default function Post({post, postViewer, isInFavorites, setShowDeletePostPopup, setPostToDelete, setShowFavoritedByList, setShowVoteByList, favoritedByUsernameList, voteByUsernameList, setFavoritedByUsernameList, setVoteByUsernameList, showPostPopup, setShowPostPopup, setReleaseMonth, setReleaseDay, setReleaseYear, setReleaseHour, setReleaseMinute, setReleaseSecond, setFileBlob, setPostToEditId, setPostToEditCaption, setPostToEdit}) { +export default function Post({post, postViewer, isInFavorites, setShowDeletePostPopup, setPostToDelete, setShowFavoritedByList, setShowVoteByList, favoritedByUsernameList, voteByUsernameList, setFavoritedByUsernameList, setVoteByUsernameList, showPostPopup, setShowPostPopup, setReleaseMonth, setReleaseDay, setReleaseYear, setReleaseHour, setReleaseMinute, setReleaseSecond, setFileBlob, setPostToEditId, setPostToEditCaption, setPostToEdit, isInComments}) { const captionCharLimit = 240; const timeAllowedToEditInSeconds = 30; const [editable, setEditable] = useState(false); @@ -39,6 +39,7 @@ export default function Post({post, postViewer, isInFavorites, setShowDeletePost const [localFinalVoteByUsernameList, setLocalFinalVoteByUsernameList] = useState(voteByUsernameList); const [copiedMessage, setCopiedMessage] = useState(''); const [isMobile, setIsMobile] = useState( window.innerWidth <= 768); + const [notVisibleReason, setNotVisibleReason] = useState(null); useEffect(() => { @@ -227,6 +228,7 @@ export default function Post({post, postViewer, isInFavorites, setShowDeletePost for (let i = 0; i < usernames.length && !visible; i++) { if (postViewer && postViewer.username === usernames[i]) { visible = true; + setNotVisibleReason(null); } } @@ -234,12 +236,30 @@ export default function Post({post, postViewer, isInFavorites, setShowDeletePost { visible = postAdmin; } + + if (!visible) + { + setNotVisibleReason('You can not see this post because is is not dedicated to you.'); + } + else + { + setNotVisibleReason(null); + } } else { visible = true; + setNotVisibleReason(null); } } + else + { + setNotVisibleReason('You can not see this post because it is not in your favorites.'); + } + } + else + { + setNotVisibleReason('You can not see this post because it is not released yet.\n' + (post.release ? ' Release: ' + getReleaseFormat() : '')); } @@ -630,6 +650,7 @@ export default function Post({post, postViewer, isInFavorites, setShowDeletePost }, []); return ( + <>
@@ -769,5 +790,31 @@ export default function Post({post, postViewer, isInFavorites, setShowDeletePost )}
+ + {isInComments && notVisibleReason && ( +
+
+
+
handleProfilePhotoClick(post.profile_picture)}> + +
+
+

navigateToProfile()}>{post.username}

+

{getReleaseFormat()}

+
+
+
+ +
+

{notVisibleReason}

+
+ + +
+ )} + ); } diff --git a/epoch_frontend/src/modules/ProtectedRoute.js b/epoch_frontend/src/modules/ProtectedRoute.js index 69547ed..36ef1a8 100644 --- a/epoch_frontend/src/modules/ProtectedRoute.js +++ b/epoch_frontend/src/modules/ProtectedRoute.js @@ -20,7 +20,6 @@ const ProtectedRoute = ({ children }) => { useEffect(() => { // Check if the session is active; if not, redirect to the login page if (!isSessionActive()) { - navigate('/epoch/login'); } }, [navigate]); diff --git a/epoch_frontend/src/pages/Comments.js b/epoch_frontend/src/pages/Comments.js index c7f751e..f7d0d88 100644 --- a/epoch_frontend/src/pages/Comments.js +++ b/epoch_frontend/src/pages/Comments.js @@ -110,7 +110,7 @@ function Comments() { setShowNewPostPopup={setShowNewPostPopup} refreshFeed={refreshComments} setRefreshFeed={setRefreshComments} viewingOnly={true} posts={[commentsPost]} isInFavorites={false} isInHashtags={false} - hashtag={null}> + hashtag={null} isInComments={true}> )} diff --git a/epoch_frontend/src/pages/Favorites.js b/epoch_frontend/src/pages/Favorites.js index 2dd318e..242c372 100644 --- a/epoch_frontend/src/pages/Favorites.js +++ b/epoch_frontend/src/pages/Favorites.js @@ -52,7 +52,7 @@ function Favorites() { currentUser={user} showNewPostPopup={showNewPostPopup} setShowNewPostPopup={setShowNewPostPopup} refreshFeed={refreshFeed} setRefreshFeed={setRefreshFeed} - isInFavorites={true}/>) : (<>)} + isInFavorites={true} isInComments={false}/>) : (<>)} {user ? ( + setRefreshFeed={setRefreshFeed} posts={null} isInFavorites={false} hashtag={hashtag} isInHashtags={true} isInComments={false}/> ) : ( + posts={null} isInFavorites={false} isInHashtags={true} hashtag={hashtag} isInComments={false}/> )} diff --git a/epoch_frontend/src/pages/home.js b/epoch_frontend/src/pages/home.js index 0c61b99..837bf08 100644 --- a/epoch_frontend/src/pages/home.js +++ b/epoch_frontend/src/pages/home.js @@ -61,7 +61,7 @@ function Home() { currentUser={user} showNewPostPopup={showNewPostPopup} setShowNewPostPopup={setShowNewPostPopup} refreshFeed={refreshFeed} setRefreshFeed={setRefreshFeed} viewingOnly={false} posts={null} - isInFavorites={false}/> + isInFavorites={false} isInComments={false}/> diff --git a/epoch_frontend/src/pages/profile.js b/epoch_frontend/src/pages/profile.js index b2b884c..ea6c342 100644 --- a/epoch_frontend/src/pages/profile.js +++ b/epoch_frontend/src/pages/profile.js @@ -400,13 +400,13 @@ function Profile() { + setRefreshFeed={setRefreshFeed} posts={null} isInFavorites={false} isInComments={false}/> ) : ( + isInFavorites={false} isInComments={false}/> )}