Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post page UI #1224

Merged
merged 8 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/components/Post/CommentDialogBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,22 @@ import {
import React, { useEffect, useState } from "react";
import { auth, db } from "../../lib/firebase";
import { doc, getDoc } from "firebase/firestore";
import { deleteComment } from "../../js/postFn";

import AccountCircleIcon from "@mui/icons-material/AccountCircle";
import DeleteTwoToneIcon from "@mui/icons-material/DeleteTwoTone";
import { Link } from "react-router-dom";
import ReadMore from "../ReadMore";

const CommentDialogBox = ({
postId,
comments,
setOpenToDeleteComment,
openToDeleteComment,
setDeleteCommentID,
user,
fullScreen,
handleCloseForDeleteComment,
deleteComment,
deleteCommentID,
}) => {
const { isAnonymous } = user;
const [username, setUsername] = useState("");
const [openToDeleteComment, setOpenToDeleteComment] = useState(false);

useEffect(() => {
async function getUsername() {
Expand Down Expand Up @@ -96,7 +93,6 @@ const CommentDialogBox = ({
<div
onClick={() => {
setOpenToDeleteComment(!openToDeleteComment);
setDeleteCommentID(userComment);
}}
>
{user && userComment?.content?.username == username && (
Expand All @@ -109,7 +105,7 @@ const CommentDialogBox = ({
<Dialog
fullScreen={fullScreen}
open={openToDeleteComment}
onClose={handleCloseForDeleteComment}
onClose={() => setOpenToDeleteComment(false)}
aria-labelledby="responsive-dialog-title"
>
<DialogTitle id="responsive-dialog-title">
Expand All @@ -121,12 +117,12 @@ const CommentDialogBox = ({
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={handleCloseForDeleteComment}>
<Button onClick={() => setOpenToDeleteComment(false)}>
Cancel
</Button>
<Button
onClick={(event) =>
deleteComment(event, deleteCommentID)
deleteComment(event, postId, userComment.id)
}
>
Delete
Expand Down
26 changes: 1 addition & 25 deletions src/components/Post/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ function Post(prop) {
const [showCommentEmojis, setShowCommentEmojis] = useState(false);
const [isCommentOpen, setisCommentOpen] = useState(false);
const [isLikesOpen, setIsLikesOpen] = useState(false);
const [deleteCommentID, setDeleteCommentID] = useState("");
const [openToDeleteComment, setOpenToDeleteComment] = useState(false);
const [username, setUsername] = useState("");

const theme = useTheme();
Expand Down Expand Up @@ -118,16 +116,6 @@ function Post(prop) {
}
};

const deleteComment = async (event, commentRef) => {
event.preventDefault();
await db
.collection("posts")
.doc(postId)
.collection("comments")
.doc(commentRef.id)
.delete();
};

const onEmojiClick = (emojiObject, event) => {
setComment((prevInput) => prevInput + emojiObject.emoji);
setShowEmojis(false);
Expand Down Expand Up @@ -191,9 +179,6 @@ function Post(prop) {
setisCommentOpen(false);
};

const handleCloseForDeleteComment = () => {
setOpenToDeleteComment(false);
};

return (
<div className={`${rowMode ? "post" : "postColumn"}`}>
Expand Down Expand Up @@ -288,19 +273,10 @@ function Post(prop) {
<hr />
<ErrorBoundary>
<CommentDialogBox
Item={Item}
postHasImages={postHasImages}
postImages={postImages}
caption={caption}
postId={postId}
comments={comments}
setOpenToDeleteComment={setOpenToDeleteComment}
openToDeleteComment={openToDeleteComment}
setDeleteCommentID={setDeleteCommentID}
user={user}
fullScreen={fullScreen}
handleCloseForDeleteComment={handleCloseForDeleteComment}
deleteComment={deleteComment}
deleteCommentID={deleteCommentID}
/>
</ErrorBoundary>
<ErrorBoundary>
Expand Down
74 changes: 0 additions & 74 deletions src/components/postView/PostViewComments.jsx

This file was deleted.

183 changes: 0 additions & 183 deletions src/components/postView/PostViewMenu.jsx

This file was deleted.

Loading
Loading