Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
BamaCharanChhandogi committed Sep 5, 2023
1 parent d80cb10 commit 7b2583f
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions src/Components/QuoraFeedbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,30 @@ function QuoraFeedbox(props) {
//Like // Dislike
const [Like, setLike] = useState(false);
const [LikeCount, setLikeCount] = useState(0);
const [Dislike, setDislike] = useState(false);
const [DislikeCount, setDislikeCount] = useState(0);
// const [Dislike, setDislike] = useState(false);
// const [DislikeCount, setDislikeCount] = useState(0);

const handelLike=()=>{
if(!Like){
setLike(true);
setLikeCount(LikeCount+1);
if(DislikeCount!=0){
setDislikeCount(DislikeCount-1);
const handelLike = () => {
if(questionId){
if (!Like) {
setLike(true);
setLikeCount(props.postLike + 1);
db.collection("question")
.doc(questionId)
.update({
postLike: LikeCount,
})
.catch((error) => {
console.error("Error adding document: ", error);
});
// if(DislikeCount!=0){
// setDislikeCount(DislikeCount-1);
// }
} else {
setLike(false);
}
}
else{
setLike(false);
}
// sending like count to server
db.collection("question")
.doc(questionId)
.update({
postLike: LikeCount,
})
.catch((error) => {
console.error("Error adding document: ", error);
});
}
};

// const handelDislike=(e)=>{
// if(!Dislike && DislikeCount==0){
Expand All @@ -82,7 +82,7 @@ function QuoraFeedbox(props) {
// console.error("Error adding document: ", error);
// });
// }

//fetching answer
useEffect(() => {
if (questionId) {
Expand Down Expand Up @@ -142,7 +142,7 @@ function QuoraFeedbox(props) {
}}
>
<div className="profile-info">
<Avatar src={props.userImg}/>
<Avatar src={props.userImg} />
<div className="profile-info-text">
<h5>{props.displayname}</h5>
</div>
Expand All @@ -163,7 +163,9 @@ function QuoraFeedbox(props) {
<img src={answer.userImg} alt="" />
<h5>{answer.displayName}</h5>
<p>
{answer.timeStamp? new Date(answer.timeStamp?.toDate()).toLocaleString(): ""}
{answer.timeStamp
? new Date(answer.timeStamp?.toDate()).toLocaleString()
: ""}
</p>
</div>
<p>
Expand Down Expand Up @@ -196,12 +198,12 @@ function QuoraFeedbox(props) {
<div className="break">|</div>
<div className="Downvote">
<ThumbDownOutlined />
<h4>{DislikeCount}</h4>
{/* <h4>{props.postDisLike}</h4> */}
</div>
</div>
<div className="Message">
{/* <div className="Message">
<ChatOutlined />
</div>
</div> */}
<div className="Share">
<ShareOutlined />
</div>
Expand Down

0 comments on commit 7b2583f

Please sign in to comment.