Skip to content

Commit

Permalink
Merge pull request #378 from Aymanhki/ayman
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
Aymanhki authored Apr 9, 2024
2 parents 324a1da + fb370cc commit 9071265
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 11 deletions.
6 changes: 4 additions & 2 deletions epoch_frontend/src/modules/Feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default function Feed({
posts,
isInFavorites,
isInHashtags,
hashtag
hashtag,
isInComments
}) {

const [isLoading, setIsLoading] = useState(true);
Expand Down Expand Up @@ -372,7 +373,8 @@ export default function Feed({
setFileBlob={setFileBlob}
setPostToEditId={setPostToEditId}
setPostToEditCaption={setPostToEditCaption}
setPostToEdit={setPostToEdit}/>
setPostToEdit={setPostToEdit}
isInComments={isInComments}/>

))
)}
Expand Down
49 changes: 48 additions & 1 deletion epoch_frontend/src/modules/Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(() => {
Expand Down Expand Up @@ -227,19 +228,38 @@ 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);
}
}

if (!visible)
{
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() : ''));
}


Expand Down Expand Up @@ -630,6 +650,7 @@ export default function Post({post, postViewer, isInFavorites, setShowDeletePost
}, []);

return (
<>
<div className={`post ${showFullCaption ? 'post-expanded' : ''}`}
style={{display: ( isPostVisible() ) ? 'block' : 'none'}}>
<div className="post-header">
Expand Down Expand Up @@ -769,5 +790,31 @@ export default function Post({post, postViewer, isInFavorites, setShowDeletePost
)}
</div>
</div>

{isInComments && notVisibleReason && (
<div className={`post`} >
<div className="post-header">
<div className="post-header-left">
<div className={'profile-photo-container'}
onClick={() => handleProfilePhotoClick(post.profile_picture)}>
<SmartMedia fileUrl={post.profile_picture} file_type={post.profile_picture_type}
file_name={post.profile_picture_name} alt="Profile" className="profile-photo"/>
</div>
<div className="post-header-info">
<h3 className={'post-username'}
onClick={() => navigateToProfile()}>{post.username}</h3>
<p className={'post-date'}>{getReleaseFormat()}</p>
</div>
</div>
</div>

<div className="post-body">
<h1>{notVisibleReason}</h1>
</div>


</div>
)}
</>
);
}
1 change: 0 additions & 1 deletion epoch_frontend/src/modules/ProtectedRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion epoch_frontend/src/pages/Comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function Comments() {
setShowNewPostPopup={setShowNewPostPopup} refreshFeed={refreshComments}
setRefreshFeed={setRefreshComments} viewingOnly={true}
posts={[commentsPost]} isInFavorites={false} isInHashtags={false}
hashtag={null}></Feed>
hashtag={null} isInComments={true}></Feed>
)}
</div>

Expand Down
2 changes: 1 addition & 1 deletion epoch_frontend/src/pages/Favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Favorites() {
currentUser={user} showNewPostPopup={showNewPostPopup}
setShowNewPostPopup={setShowNewPostPopup} refreshFeed={refreshFeed}
setRefreshFeed={setRefreshFeed}
isInFavorites={true}/>) : (<></>)}
isInFavorites={true} isInComments={false}/>) : (<></>)}
</div>
</div>
{user ? (<PostPopup showPopup={showNewPostPopup} setShowPopup={setShowNewPostPopup}
Expand Down
4 changes: 2 additions & 2 deletions epoch_frontend/src/pages/Hashtag.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ function Hashtag() {
<Feed feedUsername={user.username} feedUserId={user.id} isInProfile={false}
currentUser={user} showNewPostPopup={showNewPostPopup}
setShowNewPostPopup={setShowNewPostPopup} refreshFeed={refreshFeed}
setRefreshFeed={setRefreshFeed} posts={null} isInFavorites={false} hashtag={hashtag} isInHashtags={true}/>
setRefreshFeed={setRefreshFeed} posts={null} isInFavorites={false} hashtag={hashtag} isInHashtags={true} isInComments={false}/>
) : (
<Feed feedUsername={null} feedUserId={null} isInProfile={false} currentUser={null}
showNewPostPopup={showNewPostPopup} setShowNewPostPopup={setShowNewPostPopup}
refreshFeed={refreshFeed} setRefreshFeed={setRefreshFeed} viewingOnly={true}
posts={null} isInFavorites={false} isInHashtags={true} hashtag={hashtag}/>
posts={null} isInFavorites={false} isInHashtags={true} hashtag={hashtag} isInComments={false}/>
)}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion epoch_frontend/src/pages/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}/>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions epoch_frontend/src/pages/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,13 @@ function Profile() {
<Feed feedUsername={userInfo.username} feedUserId={userInfo.id} isInProfile={true}
currentUser={user} showNewPostPopup={showNewPostPopup}
setShowNewPostPopup={setShowNewPostPopup} refreshFeed={refreshFeed}
setRefreshFeed={setRefreshFeed} posts={null} isInFavorites={false}/>
setRefreshFeed={setRefreshFeed} posts={null} isInFavorites={false} isInComments={false}/>
) : (
<Feed feedUsername={userInfo.username} feedUserId={userInfo.id} isInProfile={true}
currentUser={null} showNewPostPopup={showNewPostPopup}
setShowNewPostPopup={setShowNewPostPopup} refreshFeed={refreshFeed}
setRefreshFeed={setRefreshFeed} viewingOnly={true} posts={null}
isInFavorites={false}/>
isInFavorites={false} isInComments={false}/>
)}
</div>
</div>
Expand Down

0 comments on commit 9071265

Please sign in to comment.