-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🥇🍥 ↝ Temporary UI changes to social component, dynamic profile state …
…management added There's an issue with loading the Avatars in the PostCard component -> we need to match them to the post id & the user who created the post [id] however it seems there's an endless loop that's been established where the client is constantly trying to communicate with the server (Supabase). The key to fixing this issue is getting the Avatar data to be passed in the same way as it is in the PostFormCard component (which is not experiencing any problems) Signal-K/sytizen#16
- Loading branch information
1 parent
b535706
commit 22cb700
Showing
9 changed files
with
190 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,48 @@ | ||
import Layout from "../../components/Layout"; | ||
import PostFormCard from "../../components/PostFormCard"; | ||
import PostCard from "../../components/PostCard"; | ||
import React from "react"; | ||
import { useSession } from "@supabase/auth-helpers-react"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; | ||
import LoginPage from "../login/social-login"; | ||
|
||
export default function SocialGraphHome() { | ||
const supabase = useSupabaseClient(); | ||
const session = useSession(); | ||
console.log(session); | ||
const [posts, setPosts] = useState([]); | ||
|
||
const [profile, setProfile] = useState(null); | ||
|
||
if (!session) { return <LoginPage /> }; | ||
|
||
function fetchPosts () { | ||
supabase.from('posts') | ||
.select('id, content, created_at, profiles(id, avatar_url, username)') // Reset id on testing playground server later | ||
.order('created_at', { ascending: false }) | ||
.then(result => { setPosts(result.data); }) | ||
} | ||
|
||
function fetchProfile () { | ||
supabase.from('profiles') | ||
.select() | ||
.eq('id', session.user.id) | ||
.then(result => { | ||
if (result.data) { | ||
setProfile(result.data[0]); | ||
} | ||
}) | ||
} | ||
|
||
fetchProfile(); | ||
fetchPosts(); | ||
|
||
/*useEffect(() => { */fetchPosts();// }, []); | ||
|
||
return ( | ||
<Layout hideNavigation={false}> | ||
<PostFormCard /> | ||
<PostCard /> | ||
<PostFormCard onPost={fetchPosts} /> | ||
{posts?.length > 0 && posts.map(post => ( | ||
<PostCard key = { post.id } {...post} /> | ||
))} | ||
</Layout> | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE POLICY "Any user can create posts" ON "public"."posts" | ||
AS PERMISSIVE FOR INSERT | ||
TO public | ||
|
||
WITH CHECK (author = auth.uid()) /* https://app.supabase.com/project/qwbufbmxkjfaikoloudl/auth/policies#27609 */ | ||
|
||
CREATE POLICY "Anyone can see all posts" ON "public"."posts" | ||
AS PERMISSIVE FOR SELECT | ||
TO public | ||
USING (true) |
Oops, something went wrong.