Bug Fixes
This commit is contained in:
@@ -9,7 +9,7 @@ function Mobile() {
|
|||||||
const [friendsPostsData, setFriendsPosts] = useState<any[]>([]);
|
const [friendsPostsData, setFriendsPosts] = useState<any[]>([]);
|
||||||
|
|
||||||
function getFriendsPosts(friendId: any) {
|
function getFriendsPosts(friendId: any) {
|
||||||
fetch(`/api/users/${friendId}/posts`)
|
fetch(`/api/user/${friendId}/posts`)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.posts) {
|
if (data.posts) {
|
||||||
@@ -25,12 +25,14 @@ function Mobile() {
|
|||||||
|
|
||||||
// Fetch friends' posts
|
// Fetch friends' posts
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isAuthenticated && session?.friends) {
|
if (isAuthenticated && session) {
|
||||||
let friendsIds = session.friends.map((friend: any) => friend.id);
|
let friendsIds = session.friends.map((friend: any) => friend);
|
||||||
|
|
||||||
|
console.log("Friends IDs:", friendsIds);
|
||||||
|
|
||||||
// use /api/users/:id to get friend data
|
// use /api/users/:id to get friend data
|
||||||
friendsIds.forEach((friendId: any) => {
|
friendsIds.forEach((friendId: any) => {
|
||||||
fetch(`/api/users/${friendId}`)
|
fetch(`/api/user/${friendId}`)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.user) {
|
if (data.user) {
|
||||||
@@ -44,7 +46,7 @@ function Mobile() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [isAuthenticated, session?.friends]);
|
}, [isAuthenticated, session]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="flex flex-col gap-[32px] row-start-2 items-center mt-10 text-white">
|
<main className="flex flex-col gap-[32px] row-start-2 items-center mt-10 text-white">
|
||||||
@@ -107,6 +109,6 @@ function Web() {
|
|||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const { isMobile, isSafari } = useDevice();
|
const { isMobile, isSafari } = useDevice();
|
||||||
if (isMobile && isSafari) return <Mobile />;
|
if (isMobile && isSafari) return Mobile();
|
||||||
else return <Web />;
|
else return Mobile();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user