From 3caa82349924d1bdd9619ff95ab1a22b8fd57b83 Mon Sep 17 00:00:00 2001 From: "max.tyson" Date: Thu, 8 Aug 2024 10:44:19 +1200 Subject: [PATCH] Work on post moderation --- website/src/pages/admin/posts.tsx | 11 ++++++++++- website/src/pages/index.tsx | 1 + website/src/pages/media/messages/[id].tsx | 16 +++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/website/src/pages/admin/posts.tsx b/website/src/pages/admin/posts.tsx index c38ea38..9e21396 100644 --- a/website/src/pages/admin/posts.tsx +++ b/website/src/pages/admin/posts.tsx @@ -11,6 +11,8 @@ import {useRouter} from "next/router"; import {Layout} from "@/components/layout"; import {RongoaUser, UserDatabaseDetails} from "@/lib/users"; import {PostCard, PostCardApi} from "@/pages/media/components/cards"; +import {getFilePath} from "@/lib/data"; +import {ModalImage} from "@/components/modal"; export default function Admin(){ const pageName = "Admin"; @@ -19,6 +21,7 @@ export default function Admin(){ const { data: session, update } = useSession() const [moderationIds, setModerationIds] = useState([]) + const [images, setImages] = useState([]) const [currentIndex, setCurrentIndex] = useState(0) const [loadingMessage, setLoadingMessage] = useState("") const [error, setError] = useState("") @@ -38,7 +41,9 @@ export default function Admin(){ if(response.data.data){ const ids = response.data.data.map((post: any) => post.id) + const images = response.data.data.map((post: any) => getFilePath(post.post_user_id, post.id, post.post_image)) setModerationIds(ids) + setImages(images) } setLoadingMessage("") @@ -85,13 +90,16 @@ export default function Admin(){

Post Moderation

+

There are {moderationIds.length} posts that need to be moderated.

{moderationIds && moderationIds.slice(currentIndex, currentIndex + 2).map((id) => ( - + + + ))} {currentIndex >= moderationIds.length && (
+
diff --git a/website/src/pages/index.tsx b/website/src/pages/index.tsx index 0d67dba..eaa9b2e 100644 --- a/website/src/pages/index.tsx +++ b/website/src/pages/index.tsx @@ -24,6 +24,7 @@ import axios from "axios"; // - Plant App // = = Moderation // - - Live Chat +// - - Better Plan Search // - - Link To Rongoa (Images Popup and Home Feed) // - - Publish on stores // - Databse diff --git a/website/src/pages/media/messages/[id].tsx b/website/src/pages/media/messages/[id].tsx index a0b95cd..0cf199f 100644 --- a/website/src/pages/media/messages/[id].tsx +++ b/website/src/pages/media/messages/[id].tsx @@ -172,6 +172,20 @@ export default function Page(){ scrollMessages(); }, [messages]); + + const setupRealtime = useRef(false); + useEffect(() => { + + if(setupRealtime.current) return; + setupRealtime.current = true; + + // Create a timeout to refresh every 3 + const interval = setInterval(() => { + fetchMessages(); + }, 3000); + + }, []); + const scrollMessages = () => { // Scroll to the bottom of the messages @@ -215,7 +229,7 @@ export default function Page(){ type={message.message_user_id === (session?.user as RongoaUser).database.id ? "sent" : "received"} /> - +sudo nano /etc/network/interfaces ) })}