Feed - posts #227

Merged
enes merged 23 commits from feat/131-feed-posts into staging 2025-02-14 19:54:29 +00:00
4 changed files with 19 additions and 10 deletions
Showing only changes of commit 30602d2e55 - Show all commits

View File

@ -2,7 +2,7 @@ import { NDKSubscriptionCacheUsage } from '@nostr-dev-kit/ndk'
import { FALLBACK_PROFILE_IMAGE } from '../../constants'
import { useAppSelector } from 'hooks'
import { useProfile } from 'hooks/useProfile'
import { Navigate, useSubmit } from 'react-router-dom'
import { Navigate, useNavigation, useSubmit } from 'react-router-dom'
import { appRoutes } from 'routes'
import { useEffect, useRef, useState } from 'react'
import { adjustTextareaHeight } from 'utils'
@ -17,6 +17,7 @@ export const NoteSubmit = ({
initialContent,
handleClose
}: NoteSubmitProps) => {
const navigation = useNavigation()
const userState = useAppSelector((state) => state.user)
const profile = useProfile(userState.user?.pubkey as string | undefined, {
cacheUsage: NDKSubscriptionCacheUsage.PARALLEL
@ -131,8 +132,9 @@ export const NoteSubmit = ({
className='btn btnMain'
type='submit'
style={{ padding: '5px 20px', borderRadius: '8px' }}
disabled={navigation.state !== 'idle'}
>
Post
{navigation.state === 'idle' ? 'Post' : 'Posting...'}
</button>
</div>
</div>

View File

@ -124,3 +124,6 @@ export const FALLBACK_PROFILE_IMAGE =
export const PROFILE_BLOG_FILTER_LIMIT = 20
export const MAX_VISIBLE_TEXT_PER_COMMENT = 500
export const CLIENT_NAME_VALUE = 'DEG Mods'
export const CLIENT_TAG_VALUE =
'31990:f4bf1fb5ba8be839f70c7331733e309f780822b311f63e01f9dc8abbb428f8d5:bf1987d6-b772-43c6-bce7-42b638a9ffed'

View File

@ -11,7 +11,12 @@ import NDK, {
zapInvoiceFromEvent
} from '@nostr-dev-kit/ndk'
import NDKCacheAdapterDexie from '@nostr-dev-kit/ndk-cache-dexie'
import { MOD_FILTER_LIMIT, T_TAG_VALUE } from 'constants.ts'
import {
CLIENT_NAME_VALUE,
CLIENT_TAG_VALUE,
MOD_FILTER_LIMIT,
T_TAG_VALUE
} from 'constants.ts'
import { Dexie } from 'dexie'
import { createContext, ReactNode, useEffect, useMemo } from 'react'
import { toast } from 'react-toastify'
@ -127,6 +132,8 @@ export const NDKContextProvider = ({ children }: { children: ReactNode }) => {
enableOutboxModel: true,
autoConnectUserRelays: true,
autoFetchUserMutelist: true,
clientName: CLIENT_NAME_VALUE,
clientNip89: CLIENT_TAG_VALUE,
explicitRelayUrls: [
'wss://user.kindpag.es',
'wss://purplepag.es',

View File

@ -44,19 +44,16 @@ export const feedPostRouteAction =
kind: NDKKind.Text,
created_at: currentTimeStamp,
content: content,
tags: [],
tags: [
['L', 'source'],
['l', window.location.host, 'source']
],
pubkey: hexPubkey
})
try {
await ndkEvent.generateTags()
if (formSubmit.nsfw) ndkEvent.tags.push(['L', 'content-warning'])
ndkEvent.tags.push(['L', 'source'])
ndkEvent.tags.push(['l', window.location.host, 'source'])
ndkEvent.tags.push(['client', 'DEG Mods'])
await ndkEvent.sign()
const note1 = ndkEvent.encode()
const publishedOnRelays = await ndkEvent.publish()