diff --git a/src/components/feeds/GlobalFeed.js b/src/components/feeds/GlobalFeed.js index f488f3e..340abe0 100644 --- a/src/components/feeds/GlobalFeed.js +++ b/src/components/feeds/GlobalFeed.js @@ -116,7 +116,7 @@ const GlobalFeed = () => {
{ const [authorData, setAuthorData] = useState({}); useEffect(() => { - communityNotes.forEach(note => { - if (!authorData[note.pubkey]) { - fetchAuthor(note.pubkey); + const fetchAuthors = async () => { + const authorDataMap = {}; + for (const message of communityNotes) { + if (!authorDataMap[message.pubkey]) { + const author = await fetchAuthor(message.pubkey); + authorDataMap[message.pubkey] = author; + } } - }); - }, [communityNotes, authorData]); + setAuthorData(authorDataMap); + }; + + if (communityNotes && communityNotes.length > 0) { + fetchAuthors(); + } + }, [communityNotes]); const fetchAuthor = async (pubkey) => { try { @@ -37,41 +46,43 @@ const NostrFeed = () => { if (author) { try { const fields = await findKind0Fields(JSON.parse(author.content)); - setAuthorData(prevData => ({ - ...prevData, - [pubkey]: fields - })); + return fields; } catch (error) { console.error('Error fetching author:', error); } } + return null; } catch (error) { console.error('Error fetching author:', error); } }; - const renderHeader = (message) => { - const author = authorData[message.pubkey]; + const getAvatarImage = (message) => { + return authorData[message.pubkey]?.avatar ? returnImageProxy(authorData[message.pubkey]?.avatar) : null; + }; - if (!author || Object.keys(author).length === 0 || !author.username || !author.avatar) { - return null; - } - - return ( -
-
- -

{author?.username || author?.pubkey.substring(0, 12) + '...'}

-
-
-
- - } value="nostr" className="w-fit text-[#f8f8ff] bg-blue-400 max-sidebar:mt-1" /> -
+ const renderHeader = (message) => ( +
+
+ +

+ {authorData[message.pubkey]?.username || message.pubkey.substring(0, 12) + '...'} +

+
+
+
+ + } value="nostr" className="w-fit text-[#f8f8ff] bg-blue-400 max-sidebar:mt-1" />
- ); - } +
+ ); const footer = (message) => (
diff --git a/src/components/navbar/navbar.module.css b/src/components/navbar/navbar.module.css index 5f9981d..6aa32f7 100644 --- a/src/components/navbar/navbar.module.css +++ b/src/components/navbar/navbar.module.css @@ -11,6 +11,8 @@ .logo { border-radius: 25px; margin-right: 8px; + max-height: 60px; + max-width: 60px; } .title { diff --git a/src/components/profile/UserProfile.js b/src/components/profile/UserProfile.js index b616b08..45bdb36 100644 --- a/src/components/profile/UserProfile.js +++ b/src/components/profile/UserProfile.js @@ -1,6 +1,7 @@ import React, { useRef, useState, useEffect } from "react"; import { DataTable } from "primereact/datatable"; import { Button } from "primereact/button"; +import { Avatar } from "primereact/avatar"; import { Menu } from "primereact/menu"; import { Column } from "primereact/column"; import { useImageProxy } from "@/hooks/useImageProxy"; diff --git a/src/components/sidebar/Sidebar.js b/src/components/sidebar/Sidebar.js index 5d695cc..2567dee 100644 --- a/src/components/sidebar/Sidebar.js +++ b/src/components/sidebar/Sidebar.js @@ -15,10 +15,6 @@ const Sidebar = () => { const { data: session } = useSession(); - const header = (text) => { - return router.push('/content')}>{text} - }; - return (
@@ -26,7 +22,7 @@ const Sidebar = () => {

Home

- ({ className: `hover:bg-gray-700 rounded-lg ${isActive('/content') || router.pathname === '/content' ? 'bg-gray-700' : ''} ${styles['p-accordion-header-link']}` @@ -34,8 +30,11 @@ const Sidebar = () => { content: styles['p-accordion-content'], header: 'text-lg' }} - header={header('Content')}> -
router.push('/content?tag=courses')} className={`w-full cursor-pointer py-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=courses') ? 'bg-gray-700' : ''}`}> + header={'Content'}> +
router.push('/content?tag=all')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=all') ? 'bg-gray-700' : ''}`}> +

All

+
+
router.push('/content?tag=courses')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=courses') ? 'bg-gray-700' : ''}`}>

Courses

router.push('/content?tag=workshops')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=workshops') ? 'bg-gray-700' : ''}`}> @@ -53,7 +52,7 @@ const Sidebar = () => {

Subscribe

- ({ className: `hover:bg-gray-700 rounded-lg ${isActive('/feed') ? 'bg-gray-700' : ''} ${styles['p-accordion-header-link']}` @@ -62,7 +61,7 @@ const Sidebar = () => { header: 'text-lg' }} header={"Community"}> -
router.push('/feed?channel=global')} className={`w-full cursor-pointer py-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=global') ? 'bg-gray-700' : ''}`}> +
router.push('/feed?channel=global')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=global') ? 'bg-gray-700' : ''}`}>

global

router.push('/feed?channel=nostr')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=nostr') ? 'bg-gray-700' : ''}`}> diff --git a/src/pages/content/index.js b/src/pages/content/index.js index daa93eb..a0a89ff 100644 --- a/src/pages/content/index.js +++ b/src/pages/content/index.js @@ -21,7 +21,7 @@ const MenuTab = ({ items, selectedTopic, onTabChange }) => { else if (item === 'Workshops') icon = 'pi pi-video'; else if (item === 'Courses') icon = 'pi pi-desktop'; - const queryParam = item === 'All' ? '' : `?tag=${item.toLowerCase()}`; + const queryParam = item === 'all' ? '' : `?tag=${item.toLowerCase()}`; const isActive = router.asPath === `/content${queryParam}`; return {