mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 02:08:47 +00:00
Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24
This commit is contained in:
commit
9449d3544b
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable prefer-arrow-callback */
|
/* eslint-disable prefer-arrow-callback */
|
||||||
/* eslint-disable promise/always-return */
|
/* eslint-disable promise/always-return */
|
||||||
const admin = require("firebase-admin");
|
const { admin, db } = require("../util/admin");
|
||||||
const { db } = require("../util/admin");
|
|
||||||
|
|
||||||
exports.putPost = (req, res) => {
|
exports.putPost = (req, res) => {
|
||||||
const newPost = {
|
const newPost = {
|
||||||
@ -33,6 +33,18 @@ exports.putPost = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.deletePost = (req, res) => {
|
||||||
|
let posts = db.collection("posts")
|
||||||
|
.where("userHandle", "==", req.user.handle)
|
||||||
|
.get()
|
||||||
|
.then((query) => {
|
||||||
|
query.forEach((snap) => {
|
||||||
|
snap.ref.delete();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
exports.getallPostsforUser = (req, res) => {
|
exports.getallPostsforUser = (req, res) => {
|
||||||
var post_query = admin
|
var post_query = admin
|
||||||
.firestore()
|
.firestore()
|
||||||
@ -62,6 +74,23 @@ exports.getallPostsforUser = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.hidePost = (req, res) => {
|
||||||
|
/* db
|
||||||
|
.collection("posts")
|
||||||
|
.doc(${req.params.postId}) */
|
||||||
|
const postId = req.body.postId;
|
||||||
|
db.doc(`/posts/${postId}`)
|
||||||
|
.update({
|
||||||
|
hidden: true
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return res.status(200).json({message: "ok"});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
return res.status(500).json(error);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
exports.getallPosts = (req, res) => {
|
exports.getallPosts = (req, res) => {
|
||||||
let posts = [];
|
let posts = [];
|
||||||
let users = {};
|
let users = {};
|
||||||
@ -149,6 +178,11 @@ exports.getOtherUsersPosts = (req, res) => {
|
|||||||
.collection("posts")
|
.collection("posts")
|
||||||
.where("userHandle", "==", req.body.handle);
|
.where("userHandle", "==", req.body.handle);
|
||||||
|
|
||||||
|
post_query += admin
|
||||||
|
.firestore()
|
||||||
|
.collection("posts")
|
||||||
|
.where("microBlogTitle", "==", "Alert").where("userHandle", "==", "Admin");
|
||||||
|
|
||||||
post_query
|
post_query
|
||||||
.get()
|
.get()
|
||||||
.then(function(myPosts) {
|
.then(function(myPosts) {
|
||||||
|
|||||||
@ -104,10 +104,12 @@ app.post("/removeSub", fbAuth, removeSub);
|
|||||||
* handlers/post.js *
|
* handlers/post.js *
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getallPostsforUser,
|
getallPostsforUser,
|
||||||
getallPosts,
|
getallPosts,
|
||||||
putPost,
|
putPost,
|
||||||
|
hidePost,
|
||||||
likePost,
|
likePost,
|
||||||
unlikePost,
|
unlikePost,
|
||||||
getLikes,
|
getLikes,
|
||||||
@ -122,6 +124,9 @@ app.get("/getallPostsforUser", fbAuth, getallPostsforUser);
|
|||||||
|
|
||||||
app.get("/getallPosts", getallPosts);
|
app.get("/getallPosts", getallPosts);
|
||||||
|
|
||||||
|
//Hides Post
|
||||||
|
app.post("/hidePost", fbAuth, hidePost);
|
||||||
|
|
||||||
// Adds one post to the database
|
// Adds one post to the database
|
||||||
app.post("/putPost", fbAuth, putPost);
|
app.post("/putPost", fbAuth, putPost);
|
||||||
|
|
||||||
|
|||||||
1177
twistter-frontend/package-lock.json
generated
1177
twistter-frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -86,7 +86,21 @@ class Home extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClickLikeButton = event => {
|
flagPost = (event) => {
|
||||||
|
// Flags a post
|
||||||
|
let postId = event.target.dataset.key ? event.target.dataset.key : event.target.parentNode.dataset.key;
|
||||||
|
console.log(postId);
|
||||||
|
axios.post(`/hidePost`, {postId})
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
// event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClickLikeButton = (event) => {
|
||||||
// Need the ternary if statement because the user can click on the text or body of the
|
// Need the ternary if statement because the user can click on the text or body of the
|
||||||
// Button and they are two different html elements
|
// Button and they are two different html elements
|
||||||
let postId = event.target.dataset.key
|
let postId = event.target.dataset.key
|
||||||
@ -119,12 +133,15 @@ class Home extends Component {
|
|||||||
let authenticated = this.props.user.authenticated;
|
let authenticated = this.props.user.authenticated;
|
||||||
let { classes } = this.props;
|
let { classes } = this.props;
|
||||||
let username = this.props.user.credentials.handle;
|
let username = this.props.user.credentials.handle;
|
||||||
console.log(this.state.following);
|
console.log(username);
|
||||||
|
var hiddenBool = true;
|
||||||
|
if (username === "Admin") {
|
||||||
|
hiddenBool = false;
|
||||||
|
}
|
||||||
|
|
||||||
let postMarkup = this.state.posts ? (
|
console.log(hiddenBool);
|
||||||
this.state.posts.map(post =>
|
let postMarkup = this.state.posts ? ( this.state.following === undefined || this.state.following === null ? <Typography>You aren't following anybody right now</Typography> :
|
||||||
this.state.following ? (
|
this.state.posts.map(post => !post.hidden && this.state.following && this.state.following.includes(post.userHandle) ? (
|
||||||
this.state.following.includes(post.userHandle) ? (
|
|
||||||
<Card className={classes.card} key={post.postId}>
|
<Card className={classes.card} key={post.postId}>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography>
|
<Typography>
|
||||||
@ -132,38 +149,33 @@ class Home extends Component {
|
|||||||
this.state.imageUrl ? (<img src={this.state.imageUrl} height="50" width="50" />) :
|
this.state.imageUrl ? (<img src={this.state.imageUrl} height="50" width="50" />) :
|
||||||
(<img src={noImage} height="50" width="50"/>)
|
(<img src={noImage} height="50" width="50"/>)
|
||||||
} */}
|
} */}
|
||||||
{post.profileImage ? (
|
{
|
||||||
<img src={post.profileImage} height="50" width="50" />
|
post.profileImage ? (<img src={post.profileImage} height="50" width="50" />) :
|
||||||
) : (
|
(<img src={noImage} height="50" width="50"/>)
|
||||||
<img src={noImage} height="50" width="50" />
|
}
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="h5">
|
|
||||||
<b>{post.userHandle}</b>
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2" color={"textSecondary"}>
|
|
||||||
{this.formatDate(post.createdAt)}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<Typography variant="h5"><b>{post.userHandle}</b></Typography>
|
||||||
|
<Typography variant="body2" color={"textSecondary"}>{this.formatDate(post.createdAt)}</Typography>
|
||||||
<br />
|
<br />
|
||||||
<Typography variant="body1">
|
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
|
||||||
<b>{post.microBlogTitle}</b>
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2">{post.quoteBody}</Typography>
|
<Typography variant="body2">{post.quoteBody}</Typography>
|
||||||
<br />
|
<br />
|
||||||
<Typography variant="body2">{post.body}</Typography>
|
<Typography variant="body2">{post.body}</Typography>
|
||||||
<br />
|
<br />
|
||||||
<Typography variant="body2">
|
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics.join(", ")}</Typography>
|
||||||
<b>Topics:</b> {post.microBlogTopics.join(", ")}
|
|
||||||
</Typography>
|
|
||||||
<br />
|
<br />
|
||||||
<Typography
|
{!hiddenBool &&
|
||||||
id={post.postId}
|
<Button
|
||||||
data-likes={post.likeCount}
|
onClick={this.flagPost}
|
||||||
variant="body2"
|
data-key={post.postId}
|
||||||
color={"textSecondary"}
|
variant = "contained"
|
||||||
|
color = "primary"
|
||||||
>
|
>
|
||||||
Likes {post.likeCount}
|
Hide Post
|
||||||
</Typography>
|
</Button>
|
||||||
|
}
|
||||||
|
|
||||||
|
<Typography id={post.postId} data-likes={post.likeCount} variant="body2" color={"textSecondary"}>Likes {post.likeCount}</Typography>
|
||||||
{/* <Like microBlog = {post.postId} count = {post.likeCount} name = {username}></Like> */}
|
{/* <Like microBlog = {post.postId} count = {post.likeCount} name = {username}></Like> */}
|
||||||
<Button
|
<Button
|
||||||
onClick={this.handleClickLikeButton}
|
onClick={this.handleClickLikeButton}
|
||||||
@ -171,22 +183,20 @@ class Home extends Component {
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="primary"
|
color="primary"
|
||||||
>
|
>{
|
||||||
{this.state.likes && this.state.likes.includes(post.postId)
|
this.state.likes && this.state.likes.includes(post.postId) ? 'Unlike' : 'Like'
|
||||||
? "Unlike"
|
}</Button>
|
||||||
: "Like"}
|
<Quote microblog = {post.postId}></Quote>
|
||||||
</Button>
|
|
||||||
<Quote microblog={post.postId}></Quote>
|
|
||||||
|
|
||||||
{/* <button>Quote</button> */}
|
{/* <button>Quote</button> */}
|
||||||
|
|
||||||
|
<Typography variant="body2" color={"textSecondary"}>Likes {post.likeCount} Comments {post.commentCount}</Typography>
|
||||||
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
) : (
|
) : (
|
||||||
<p></p>
|
<p></p>
|
||||||
)
|
)
|
||||||
) : (
|
|
||||||
<p></p>
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<p>Loading post...</p>
|
<p>Loading post...</p>
|
||||||
@ -425,7 +435,7 @@ class Like extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClick() {
|
handleClick(){
|
||||||
this.setState({
|
this.setState({
|
||||||
like: !this.state.like
|
like: !this.state.like
|
||||||
});
|
});
|
||||||
|
|||||||
@ -83,6 +83,10 @@ const styles = {
|
|||||||
wordBreak: "break-all",
|
wordBreak: "break-all",
|
||||||
color: 'black'
|
color: 'black'
|
||||||
},
|
},
|
||||||
|
dmRecentMessageDisabled: {
|
||||||
|
wordBreak: "break-all",
|
||||||
|
color: 'red'
|
||||||
|
},
|
||||||
dmListItemContainer: {
|
dmListItemContainer: {
|
||||||
height: 100
|
height: 100
|
||||||
},
|
},
|
||||||
@ -426,9 +430,15 @@ export class directMessages extends Component {
|
|||||||
<Typography
|
<Typography
|
||||||
className={
|
className={
|
||||||
this.state.selectedChannel && this.state.selectedChannel.dmId === channel.dmId ? (
|
this.state.selectedChannel && this.state.selectedChannel.dmId === channel.dmId ? (
|
||||||
|
channel.hasDirectMessagesEnabled ?
|
||||||
classes.dmRecentMessageSelected
|
classes.dmRecentMessageSelected
|
||||||
|
:
|
||||||
|
classes.dmRecentMessageDisabled
|
||||||
) : (
|
) : (
|
||||||
|
channel.hasDirectMessagesEnabled ?
|
||||||
classes.dmRecentMessageUnselected
|
classes.dmRecentMessageUnselected
|
||||||
|
:
|
||||||
|
classes.dmRecentMessageDisabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -36,6 +36,7 @@ export const getUserData = () => (dispatch) => {
|
|||||||
|
|
||||||
// Sends login data to firebase and sets the user data in Redux
|
// Sends login data to firebase and sets the user data in Redux
|
||||||
export const loginUser = (loginData, history) => (dispatch) => {
|
export const loginUser = (loginData, history) => (dispatch) => {
|
||||||
|
dispatch({type: CLEAR_ERRORS});
|
||||||
dispatch({ type: LOADING_UI });
|
dispatch({ type: LOADING_UI });
|
||||||
axios
|
axios
|
||||||
.post("/login", loginData)
|
.post("/login", loginData)
|
||||||
@ -57,6 +58,7 @@ export const loginUser = (loginData, history) => (dispatch) => {
|
|||||||
|
|
||||||
// Sends signup data to firebase and sets the user data in Redux
|
// Sends signup data to firebase and sets the user data in Redux
|
||||||
export const signupUser = (newUserData, history) => (dispatch) => {
|
export const signupUser = (newUserData, history) => (dispatch) => {
|
||||||
|
dispatch({type: CLEAR_ERRORS});
|
||||||
dispatch({ type: LOADING_UI });
|
dispatch({ type: LOADING_UI });
|
||||||
axios
|
axios
|
||||||
.post("/signup", newUserData)
|
.post("/signup", newUserData)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user