diff --git a/src/components/Post/Post.jsx b/src/components/Post/Post.jsx index bff078d..045f3e7 100644 --- a/src/components/Post/Post.jsx +++ b/src/components/Post/Post.jsx @@ -22,7 +22,7 @@ import { // Components import Comment from "../Comment/Comment"; -const Post = ({ post }) => { +const Post = ({ post, reloadPage }) => { const [isLiked, setLiked] = useState(false); const [likeCount, setLikeCount] = useState(post.likes.count) const [date, setDate] = useState(); @@ -63,6 +63,7 @@ const Post = ({ post }) => { // Handle delete const handleDelete = async() => { await axios.post(`/api/posts/${post._id}/delete`, {}, axiosConfig); + reloadPage(); } // Comment submit @@ -88,6 +89,8 @@ const Post = ({ post }) => { // Load API data useEffect(() => { + + // Check like status const getLikeStatus = async () => { try { diff --git a/src/pages/Timeline/Timeline.jsx b/src/pages/Timeline/Timeline.jsx index 6809cb9..887df16 100644 --- a/src/pages/Timeline/Timeline.jsx +++ b/src/pages/Timeline/Timeline.jsx @@ -13,25 +13,26 @@ import SuggestedUsers from "../../components/SuggestedUsers/SuggestedUsers"; const Timeline = () => { const[loading, setLoadingState] = useState(true); - const [timeline, setTimeline] = useState([]); + const[timeline, setTimeline] = useState([]); + const[reload, initReload] = useState(false); + + const reloadPage = () => { + initReload(!reload); + } - // Once on mount useEffect(() => { setLoadingState(true); - // API function const getTimeline = async () => { try { const response = await axios.get('/api/posts'); setTimeline(response.data); setLoadingState(false); } catch (err) { - console.log(err); + alert(err); } } - // Call API function getTimeline(); - - }, []); + }, [reload]); return( loading === true ? : @@ -41,7 +42,7 @@ const Timeline = () => { {timeline.map(post => { return (
  • - +
  • ); })} diff --git a/src/root.css b/src/root.css index 38305f3..f71d09c 100644 --- a/src/root.css +++ b/src/root.css @@ -28,7 +28,6 @@ body, --icon-post-size: 5rem; color: var(--dark-gray); - background-color: #FFFFFF; width: 100vw; height: 100vh; diff --git a/src/utils/ImageFormat.js b/src/utils/ImageFormat.js index a0f965b..6d603eb 100644 --- a/src/utils/ImageFormat.js +++ b/src/utils/ImageFormat.js @@ -4,14 +4,14 @@ const ImageFormat = (img) => { // Returns guest img if undefined if(undefined === img){ return { - backgroundImage: `url(${'../../public/user-solid.svg'})`, + backgroundImage: `url(${'../../user-solid.svg'})`, backgroundSize: 'contain', backgroundPositionY: '3px', backgroundColor: 'var(--medium-gray)' } } - // Determine if img type is url or base64 + // Determine if img type is url or base64 and return corresponding style if(img.substring(0,4) === 'http'){ return { backgroundImage: `url(${img})` } } else {