Merge pull request 'fix: use naddr instead of nevent' (#22) from naddr into staging
All checks were successful
Release to Staging / build_and_release (push) Successful in 43s

Reviewed-on: #22
This commit is contained in:
s 2024-08-26 12:13:10 +00:00
commit dc19e614df
5 changed files with 33 additions and 43 deletions

View File

@ -204,6 +204,9 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
const uuid = uuidv4() const uuid = uuidv4()
const currentTimeStamp = now() const currentTimeStamp = now()
const aTag =
formState.aTag || `${kinds.ClassifiedListing}:${hexPubkey}:${uuid}`
const unsignedEvent: UnsignedEvent = { const unsignedEvent: UnsignedEvent = {
kind: kinds.ClassifiedListing, kind: kinds.ClassifiedListing,
created_at: currentTimeStamp, created_at: currentTimeStamp,
@ -211,10 +214,7 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
content: formState.body, content: formState.body,
tags: [ tags: [
['d', formState.dTag || uuid], ['d', formState.dTag || uuid],
[ ['a', aTag],
'a',
formState.aTag || `${kinds.ClassifiedListing}:${hexPubkey}:${uuid}`
],
['r', formState.rTag], ['r', formState.rTag],
['t', T_TAG_VALUE], ['t', T_TAG_VALUE],
[ [
@ -267,14 +267,14 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
)}` )}`
) )
const nevent = nip19.neventEncode({ const naddr = nip19.naddrEncode({
id: signedEvent.id, identifier: aTag,
author: signedEvent.pubkey, pubkey: signedEvent.pubkey,
kind: signedEvent.kind, kind: signedEvent.kind,
relays: publishedOnRelays relays: publishedOnRelays
}) })
navigate(getModsInnerPageRoute(nevent)) navigate(getModsInnerPageRoute(naddr))
} }
setIsPublishing(false) setIsPublishing(false)

View File

@ -40,26 +40,21 @@ import { ZapButtons, ZapPresets, ZapQR } from '../components/Zap'
import { getModsEditPageRoute } from '../routes' import { getModsEditPageRoute } from '../routes'
export const InnerModPage = () => { export const InnerModPage = () => {
const { nevent } = useParams() const { naddr } = useParams()
const [modData, setModData] = useState<ModDetails>() const [modData, setModData] = useState<ModDetails>()
const [isFetching, setIsFetching] = useState(true) const [isFetching, setIsFetching] = useState(true)
useDidMount(async () => { useDidMount(async () => {
if (nevent) { if (naddr) {
const decoded = nip19.decode<'nevent'>(nevent as `nevent1${string}`) const decoded = nip19.decode<'naddr'>(naddr as `naddr1${string}`)
const eventId = decoded.data.id const { identifier, kind, pubkey, relays = [] } = decoded.data
const kind = decoded.data.kind
const author = decoded.data.author
const relays = decoded.data.relays || []
const filter: Filter = { const filter: Filter = {
ids: [eventId] '#a': [identifier],
authors: [pubkey],
kinds: [kind]
} }
if (kind) filter.kinds = [kind]
if (author) filter.authors = [author]
RelayController.getInstance() RelayController.getInstance()
.fetchEvent(filter, relays) .fetchEvent(filter, relays)
.then((event) => { .then((event) => {
@ -115,7 +110,7 @@ export const InnerModPage = () => {
<div className='IBMSMSplitMainBigSide'> <div className='IBMSMSplitMainBigSide'>
<div className='IBMSMSplitMainBigSideSec'> <div className='IBMSMSplitMainBigSideSec'>
<Game <Game
nevent={nevent!} naddr={naddr!}
game={modData.game} game={modData.game}
author={modData.author} author={modData.author}
/> />
@ -198,12 +193,12 @@ export const InnerModPage = () => {
} }
type GameProps = { type GameProps = {
nevent: string naddr: string
game: string game: string
author: string author: string
} }
const Game = ({ nevent, game, author }: GameProps) => { const Game = ({ naddr, game, author }: GameProps) => {
const navigate = useNavigate() const navigate = useNavigate()
const userState = useAppSelector((state) => state.user) const userState = useAppSelector((state) => state.user)
@ -241,7 +236,7 @@ const Game = ({ nevent, game, author }: GameProps) => {
{userState.auth && userState.user?.pubkey === author && ( {userState.auth && userState.user?.pubkey === author && (
<a <a
className='dropdown-item dropdownMainMenuItem' className='dropdown-item dropdownMainMenuItem'
onClick={() => navigate(getModsEditPageRoute(nevent))} onClick={() => navigate(getModsEditPageRoute(naddr))}
> >
<svg <svg
xmlns='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg'

View File

@ -176,9 +176,9 @@ export const ModsPage = () => {
handleClick={() => handleClick={() =>
navigate( navigate(
getModsInnerPageRoute( getModsInnerPageRoute(
nip19.neventEncode({ nip19.naddrEncode({
id: mod.id, identifier: mod.aTag,
author: mod.author, pubkey: mod.author,
kind: kinds.ClassifiedListing kind: kinds.ClassifiedListing
}) })
) )

View File

@ -15,7 +15,7 @@ import { useDidMount } from '../hooks'
export const SubmitModPage = () => { export const SubmitModPage = () => {
const location = useLocation() const location = useLocation()
const { nevent } = useParams() const { naddr } = useParams()
const [modData, setModData] = useState<ModDetails>() const [modData, setModData] = useState<ModDetails>()
const [isFetching, setIsFetching] = useState(false) const [isFetching, setIsFetching] = useState(false)
@ -24,21 +24,16 @@ export const SubmitModPage = () => {
: 'Submit a mod' : 'Submit a mod'
useDidMount(async () => { useDidMount(async () => {
if (nevent) { if (naddr) {
const decoded = nip19.decode<'nevent'>(nevent as `nevent1${string}`) const decoded = nip19.decode<'naddr'>(naddr as `naddr1${string}`)
const eventId = decoded.data.id const { identifier, kind, pubkey, relays = [] } = decoded.data
const kind = decoded.data.kind
const author = decoded.data.author
const relays = decoded.data.relays || []
const filter: Filter = { const filter: Filter = {
ids: [eventId] '#a': [identifier],
authors: [pubkey],
kinds: [kind]
} }
if (kind) filter.kinds = [kind]
if (author) filter.authors = [author]
setIsFetching(true) setIsFetching(true)
RelayController.getInstance() RelayController.getInstance()
.fetchEvent(filter, relays) .fetchEvent(filter, relays)

View File

@ -13,11 +13,11 @@ export const appRoutes = {
home: '/home', home: '/home',
games: '/games', games: '/games',
mods: '/mods', mods: '/mods',
modsInner: '/mods-inner/:nevent', modsInner: '/mods-inner/:naddr',
about: '/about', about: '/about',
blog: '/blog', blog: '/blog',
submitMod: '/submit-mod', submitMod: '/submit-mod',
editMod: '/edit-mod/:nevent', editMod: '/edit-mod/:naddr',
write: '/write', write: '/write',
settingsProfile: '/settings-profile', settingsProfile: '/settings-profile',
settingsRelays: '/settings-relays', settingsRelays: '/settings-relays',
@ -26,10 +26,10 @@ export const appRoutes = {
} }
export const getModsInnerPageRoute = (eventId: string) => export const getModsInnerPageRoute = (eventId: string) =>
appRoutes.modsInner.replace(':nevent', eventId) appRoutes.modsInner.replace(':naddr', eventId)
export const getModsEditPageRoute = (eventId: string) => export const getModsEditPageRoute = (eventId: string) =>
appRoutes.editMod.replace(':nevent', eventId) appRoutes.editMod.replace(':naddr', eventId)
export const routes = [ export const routes = [
{ {