mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex-taker-v2.git
synced 2026-09-21 16:52:01 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98603d3fc5 | ||
|
|
0f16c3e0fb |
@@ -49,7 +49,7 @@ function AppBody (props) {
|
|||||||
<Route path='/sign' element={<SignMessage appData={appData} />} />
|
<Route path='/sign' element={<SignMessage appData={appData} />} />
|
||||||
<Route path='/configuration' element={<ServerSelectView appData={appData} />} />
|
<Route path='/configuration' element={<ServerSelectView appData={appData} />} />
|
||||||
<Route path='/nostr-post' element={<NostrPost appData={appData} />} />
|
<Route path='/nostr-post' element={<NostrPost appData={appData} />} />
|
||||||
<Route path='/nostr-read' element={<NostrRead appData={appData} />} />
|
<Route path='/nostr-read/:npub' element={<NostrRead appData={appData} />} />
|
||||||
<Route path='/global-feed' element={<GlobalFeed appData={appData} />} />
|
<Route path='/global-feed' element={<GlobalFeed appData={appData} />} />
|
||||||
<Route path='/content-creators' element={<ContentCreators appData={appData} />} />
|
<Route path='/content-creators' element={<ContentCreators appData={appData} />} />
|
||||||
<Route path='/user-data/:tokenId' element={<UserDataReview appData={appData} />} />
|
<Route path='/user-data/:tokenId' element={<UserDataReview appData={appData} />} />
|
||||||
|
|||||||
@@ -45,26 +45,31 @@ function ContentCard (props) {
|
|||||||
}
|
}
|
||||||
}, [loaded, creator])
|
}, [loaded, creator])
|
||||||
|
|
||||||
|
const goToProfile = () => {
|
||||||
|
const profileUrl = `${window.location.origin}/nostr-read/${creator.npub}`
|
||||||
|
window.open(profileUrl, '_blank')
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<>
|
<>
|
||||||
<Card className='mb-4 bg-light rounded-4 shadow-sm border-0'>
|
<Card className='mb-4 bg-light rounded-4 shadow-sm border-0'>
|
||||||
<Card.Body className='p-4'>
|
<Card.Body className='p-4'>
|
||||||
{/* Desktop Layout - Horizontal */}
|
{/* Desktop Layout - Horizontal */}
|
||||||
<div className='d-flex justify-content-end mb-2'>
|
<div className='d-flex justify-content-end mb-2' onClick={goToProfile}>
|
||||||
<small className='text-muted'>
|
<small className='text-muted'>
|
||||||
{new Date(creator.createdAt).toLocaleString()}
|
{new Date(creator.createdAt).toLocaleString()}
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div className='d-none d-md-flex align-items-center gap-4'>
|
<div className='d-none d-md-flex align-items-center gap-4 cursor-pointer'>
|
||||||
{/* Profile Picture */}
|
{/* Profile Picture */}
|
||||||
<div className='flex-shrink-0'>
|
<div className='flex-shrink-0' onClick={goToProfile}>
|
||||||
<Jdenticon size='140' value={creator.npub} />
|
<Jdenticon size='140' value={creator.npub} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Creator Info */}
|
{/* Creator Info */}
|
||||||
<div className='flex-grow-1'>
|
<div className='flex-grow-1'>
|
||||||
<h5 className='mb-2 fw-bold'>{profile.name}</h5>
|
<h5 className='mb-2 fw-bold cursor-pointer' onClick={goToProfile}>{profile.name}</h5>
|
||||||
<p className='text-muted medium mb-3'>{profile.about}</p>
|
<p className='text-muted medium mb-3'>{profile.about}</p>
|
||||||
|
|
||||||
{/* Nostr Public Key */}
|
{/* Nostr Public Key */}
|
||||||
@@ -126,12 +131,12 @@ function ContentCard (props) {
|
|||||||
<div className='d-flex d-md-none flex-column align-items-center text-center'>
|
<div className='d-flex d-md-none flex-column align-items-center text-center'>
|
||||||
{/* Profile Picture */}
|
{/* Profile Picture */}
|
||||||
<div className='mb-3'>
|
<div className='mb-3'>
|
||||||
<Jdenticon size='100' value={creator.npub} />
|
<Jdenticon size='100' value={creator.npub} onClick={goToProfile} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Creator Info */}
|
{/* Creator Info */}
|
||||||
<div className='w-100 mb-3'>
|
<div className='w-100 mb-3'>
|
||||||
<h5 className='mb-2 fw-bold'>{profile.name}</h5>
|
<h5 className='mb-2 fw-bold' onClick={goToProfile}>{profile.name}</h5>
|
||||||
<p className='text-muted small mb-3'>{profile.about}</p>
|
<p className='text-muted small mb-3'>{profile.about}</p>
|
||||||
|
|
||||||
{/* Nostr Public Key */}
|
{/* Nostr Public Key */}
|
||||||
|
|||||||
@@ -7,14 +7,17 @@ import React, { useState } from 'react'
|
|||||||
import { Container } from 'react-bootstrap'
|
import { Container } from 'react-bootstrap'
|
||||||
import ProfileRead from './profile-read.js'
|
import ProfileRead from './profile-read.js'
|
||||||
import PublicRead from './public-read.js'
|
import PublicRead from './public-read.js'
|
||||||
|
import { useParams } from 'react-router-dom'
|
||||||
|
|
||||||
function NostrRead (props) {
|
function NostrRead (props) {
|
||||||
const [profile, setProfile] = useState(false)
|
const [profile, setProfile] = useState(false)
|
||||||
|
const { npub } = useParams()
|
||||||
|
console.log('npub', npub)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Container>
|
<Container>
|
||||||
<ProfileRead {...props} setProfile={setProfile} />
|
<ProfileRead {...props} setProfile={setProfile} npub={npub} />
|
||||||
<PublicRead {...props} profile={profile} />
|
<PublicRead {...props} profile={profile} npub={npub} />
|
||||||
</Container>
|
</Container>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,21 +9,27 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|||||||
import { faUser } from '@fortawesome/free-solid-svg-icons'
|
import { faUser } from '@fortawesome/free-solid-svg-icons'
|
||||||
import NostrFormat from '../nostr-format'
|
import NostrFormat from '../nostr-format'
|
||||||
import { RelayPool } from 'nostr'
|
import { RelayPool } from 'nostr'
|
||||||
|
import * as nip19 from 'nostr-tools/nip19'
|
||||||
|
|
||||||
function ProfileRead (props) {
|
function ProfileRead (props) {
|
||||||
|
const { npub } = props
|
||||||
const { bchWalletState } = props.appData
|
const { bchWalletState } = props.appData
|
||||||
|
console.log('npub prop', npub)
|
||||||
const { setProfile } = props
|
const { setProfile } = props
|
||||||
const [post, setPost] = useState({})
|
const [post, setPost] = useState({})
|
||||||
const [loaded, setLoaded] = useState(false)
|
const [loaded, setLoaded] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const start = () => {
|
const start = () => {
|
||||||
const { nostrKeyPair } = bchWalletState
|
const pubHexData = nip19.decode(npub)
|
||||||
|
const pubHex = pubHexData.data
|
||||||
|
console.log('pubhex', pubHex)
|
||||||
const psf = 'wss://nostr-relay.psfoundation.info'
|
const psf = 'wss://nostr-relay.psfoundation.info'
|
||||||
|
|
||||||
const pool = RelayPool([psf])
|
const pool = RelayPool([psf])
|
||||||
pool.on('open', relay => {
|
pool.on('open', relay => {
|
||||||
relay.subscribe('subid', { limit: 5, kinds: [0], authors: [nostrKeyPair.pubHex] })
|
relay.subscribe('subid', { limit: 5, kinds: [0], authors: [pubHex] })
|
||||||
|
setLoaded(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
pool.on('eose', relay => {
|
pool.on('eose', relay => {
|
||||||
@@ -42,10 +48,10 @@ function ProfileRead (props) {
|
|||||||
setLoaded(true)
|
setLoaded(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loaded) {
|
if (!loaded && npub) {
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
}, [bchWalletState, loaded, setProfile])
|
}, [bchWalletState, loaded, setProfile, npub])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|||||||
import { faUser } from '@fortawesome/free-solid-svg-icons'
|
import { faUser } from '@fortawesome/free-solid-svg-icons'
|
||||||
import NostrFormat from '../nostr-format'
|
import NostrFormat from '../nostr-format'
|
||||||
import { RelayPool } from 'nostr'
|
import { RelayPool } from 'nostr'
|
||||||
|
import * as nip19 from 'nostr-tools/nip19'
|
||||||
|
|
||||||
function PublicRead (props) {
|
function PublicRead (props) {
|
||||||
|
const { npub } = props
|
||||||
const { bchWalletState } = props.appData
|
const { bchWalletState } = props.appData
|
||||||
const [posts, setPosts] = useState([])
|
const [posts, setPosts] = useState([])
|
||||||
const [loaded, setLoaded] = useState(false)
|
const [loaded, setLoaded] = useState(false)
|
||||||
@@ -17,13 +19,15 @@ function PublicRead (props) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Get Last post from a author
|
// Get Last post from a author
|
||||||
const start = () => {
|
const start = () => {
|
||||||
const { nostrKeyPair } = bchWalletState
|
const pubHexData = nip19.decode(npub)
|
||||||
|
const pubHex = pubHexData.data
|
||||||
|
console.log('pubhex', pubHex)
|
||||||
const psf = 'wss://nostr-relay.psfoundation.info'
|
const psf = 'wss://nostr-relay.psfoundation.info'
|
||||||
|
|
||||||
const pool = RelayPool([psf])
|
const pool = RelayPool([psf])
|
||||||
pool.on('open', relay => {
|
pool.on('open', relay => {
|
||||||
relay.subscribe('subid', { limit: 5, kinds: [1], authors: [nostrKeyPair.pubHex] })
|
relay.subscribe('subid', { limit: 5, kinds: [1], authors: [pubHex] })
|
||||||
|
setLoaded(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
pool.on('eose', relay => {
|
pool.on('eose', relay => {
|
||||||
@@ -38,10 +42,10 @@ function PublicRead (props) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loaded) {
|
if (!loaded && npub) {
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
}, [bchWalletState, loaded])
|
}, [bchWalletState, loaded, npub])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className='mt-4'>
|
<Container className='mt-4'>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import Logo from './psf-logo.png'
|
|||||||
|
|
||||||
function NavMenu (props) {
|
function NavMenu (props) {
|
||||||
// Get the current path
|
// Get the current path
|
||||||
const { currentPath } = props.appData
|
const { currentPath, bchWalletState } = props.appData
|
||||||
|
|
||||||
// Navbar state
|
// Navbar state
|
||||||
const [expanded, setExpanded] = useState(false)
|
const [expanded, setExpanded] = useState(false)
|
||||||
@@ -72,7 +72,7 @@ function NavMenu (props) {
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
<NavLink
|
<NavLink
|
||||||
className={currentPath === '/nostr-read' ? 'nav-link-active' : 'nav-link-inactive'}
|
className={currentPath === '/nostr-read' ? 'nav-link-active' : 'nav-link-inactive'}
|
||||||
to='/nostr-read'
|
to={`/nostr-read/${bchWalletState?.nostrKeyPair?.npub}`}
|
||||||
onClick={handleClickEvent}
|
onClick={handleClickEvent}
|
||||||
>
|
>
|
||||||
Nostr Profile
|
Nostr Profile
|
||||||
|
|||||||
Reference in New Issue
Block a user