Sign with block height

This commit is contained in:
KoalaSat 2023-03-11 22:48:35 +01:00
parent 0c269a1019
commit a3cbf30158
No known key found for this signature in database
GPG Key ID: 2F7F61C6146AB157
18 changed files with 130 additions and 72 deletions

View File

@ -37,7 +37,7 @@ export const GroupHeaderIcon: React.FC<GroupHeaderIconProps> = ({ groupId }) =>
const { t } = useTranslation('common')
const { database } = useContext(AppContext)
const { publicKey } = useContext(UserContext)
const { relayPool, lastEventId } = useContext(RelayPoolContext)
const { sendEvent, lastEventId } = useContext(RelayPoolContext)
const theme = useTheme()
const [group, setGroup] = useState<Group>()
const [user, setUser] = useState<User>()
@ -91,7 +91,7 @@ export const GroupHeaderIcon: React.FC<GroupHeaderIconProps> = ({ groupId }) =>
pubkey: publicKey,
tags: [['e', group?.id, '']],
}
relayPool?.sendEvent(event)
sendEvent(event)
bottomSheetEditGroupRef.current?.close()
}
}

View File

@ -12,7 +12,7 @@ import { StyleSheet, View } from 'react-native'
import { RelayPoolContext } from '../../Contexts/RelayPoolContext'
import { AppContext } from '../../Contexts/AppContext'
import { t } from 'i18next'
import { isContentWarning } from '../../Functions/RelayFunctions/Events'
import { getBitcoinTag, isContentWarning } from '../../Functions/RelayFunctions/Events'
import { type Event } from '../../lib/nostr/Events'
import { getUnixTime } from 'date-fns'
import { type Relay, searchRelays } from '../../Functions/DatabaseFunctions/Relays'
@ -72,7 +72,7 @@ export const NoteCard: React.FC<NoteCardProps> = ({
}) => {
const theme = useTheme()
const { publicKey, privateKey, mutedUsers } = React.useContext(UserContext)
const { relayPool, lastEventId, addRelayItem } = useContext(RelayPoolContext)
const { sendEvent, lastEventId, addRelayItem } = useContext(RelayPoolContext)
const {
database,
showSensitive,
@ -98,6 +98,7 @@ export const NoteCard: React.FC<NoteCardProps> = ({
const [loadingZap, setLoadingZap] = React.useState<boolean>(false)
const [mutedUser, setMutedUser] = React.useState<boolean>(false)
const [zapInvoice, setZapInvoice] = React.useState<string>()
const [bitcoinTag, setBitcoinTag] = React.useState<string[]>()
useEffect(() => {
if (database && publicKey && note?.id) {
@ -125,6 +126,7 @@ export const NoteCard: React.FC<NoteCardProps> = ({
}
getNoteRelays(database, note.id).then(setRelays)
setMutedUser(mutedUsers.find((e) => e === note.pubkey) !== undefined)
setBitcoinTag(getBitcoinTag(note)[0] ?? undefined)
}
}, [lastEventId])
@ -154,7 +156,7 @@ export const NoteCard: React.FC<NoteCardProps> = ({
pubkey: publicKey,
tags: [...note.tags, ['e', note.id], ['p', note.pubkey]],
}
relayPool?.sendEvent(event)
sendEvent(event)
}
}
@ -412,6 +414,7 @@ export const NoteCard: React.FC<NoteCardProps> = ({
lnAddress={note?.ln_address}
picture={showAvatarImage ? note?.picture : undefined}
timestamp={note?.created_at}
bitcoinTag={bitcoinTag}
/>
</TouchableRipple>
</View>

View File

@ -35,7 +35,7 @@ export const ProfileActions: React.FC<ProfileActionsProps> = ({
const theme = useTheme()
const { database } = React.useContext(AppContext)
const { publicKey, privateKey, mutedUsers, reloadLists } = React.useContext(UserContext)
const { relayPool, updateRelayItem, lastEventId } = React.useContext(RelayPoolContext)
const { relayPool, updateRelayItem, lastEventId, sendEvent } = React.useContext(RelayPoolContext)
const [isContact, setIsContact] = React.useState<boolean>()
const [isMuted, setIsMuted] = React.useState<boolean>()
const [isGroupHidden, setIsGroupHidden] = React.useState<boolean>()
@ -68,8 +68,7 @@ export const ProfileActions: React.FC<ProfileActionsProps> = ({
const hideGroupsUser: () => void = () => {
if (publicKey && relayPool && database && user.id) {
relayPool
?.sendEvent({
sendEvent({
content: '',
created_at: getUnixTime(new Date()),
kind: Kind.ChannelMuteUser,

View File

@ -6,6 +6,7 @@ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityI
import NostrosAvatar from '../NostrosAvatar'
import { getNpub } from '../../lib/nostr/Nip19'
import { formatDate } from '../../Functions/NativeFunctions'
import { AppContext } from '../../Contexts/AppContext'
interface ProfileCardProps {
username?: string
@ -17,6 +18,7 @@ interface ProfileCardProps {
picture?: string
avatarSize?: number
timestamp?: number
bitcoinTag?: string[]
}
export const ProfileData: React.FC<ProfileCardProps> = ({
@ -29,8 +31,10 @@ export const ProfileData: React.FC<ProfileCardProps> = ({
picture,
avatarSize,
timestamp,
bitcoinTag
}) => {
const theme = useTheme()
const { signHeight } = React.useContext(AppContext)
const nPub = React.useMemo(() => (publicKey ? getNpub(publicKey) : ''), [publicKey])
const date = React.useMemo(() => formatDate(timestamp), [timestamp])
@ -62,6 +66,7 @@ export const ProfileData: React.FC<ProfileCardProps> = ({
</View>
<Text numberOfLines={1}>
{timestamp ? date : validNip05 ? getNip05Domain(nip05) : ''}
{signHeight && bitcoinTag ? ` (${bitcoinTag[2]})` : ''}
</Text>
</View>
</View>

View File

@ -42,7 +42,7 @@ interface RelayCardProps {
export const RelayCard: React.FC<RelayCardProps> = ({ url, bottomSheetRef }) => {
const theme = useTheme()
const { publicKey } = React.useContext(UserContext)
const { updateRelayItem, relayPool, removeRelayItem, sendRelays } =
const { updateRelayItem, relayPool, removeRelayItem, sendRelays, sendEvent } =
React.useContext(RelayPoolContext)
const { database } = React.useContext(AppContext)
const [relay, setRelay] = React.useState<Relay>()
@ -67,20 +67,20 @@ export const RelayCard: React.FC<RelayCardProps> = ({ url, bottomSheetRef }) =>
getRawUserNotes(database, publicKey).then((resultNotes) => {
resultNotes.forEach((note) => {
note.content = note.content.replace("''", "'")
relayPool.sendEvent(note, url)
sendEvent(note, url)
})
setPushDone(true)
setShowNotification('pushCompleted')
})
getRawUserReactions(database, publicKey).then((resultReactions) => {
resultReactions.forEach((reaction) => {
relayPool.sendEvent(reaction, url)
sendEvent(reaction, url)
})
})
getRawUserConversation(database, publicKey).then((resultConversations) => {
resultConversations.forEach((conversation) => {
conversation.content = conversation.content.replace("''", "'")
relayPool.sendEvent(conversation, url)
sendEvent(conversation, url)
})
})
getUsers(database, { exludeIds: [publicKey], contacts: true }).then((users) => {
@ -92,27 +92,27 @@ export const RelayCard: React.FC<RelayCardProps> = ({ url, bottomSheetRef }) =>
pubkey: publicKey,
tags: usersToTags(users),
}
relayPool?.sendEvent(event, url)
sendEvent(event, url)
}
})
getRawUserGroupMessages(database, publicKey).then((resultGroupMessages) => {
resultGroupMessages.forEach((groupMessage) => {
relayPool.sendEvent(groupMessage, url)
sendEvent(groupMessage, url)
})
})
getRawUserGroups(database, publicKey).then((resultGroups) => {
resultGroups.forEach((group) => {
relayPool.sendEvent(group, url)
sendEvent(group, url)
})
})
getRawLists(database, publicKey).then((lists) => {
lists.forEach((list) => {
relayPool.sendEvent(list, url)
sendEvent(list, url)
})
})
getRawRelayMetadata(database, publicKey).then((lists) => {
lists.forEach((list) => {
relayPool.sendEvent(list, url)
sendEvent(list, url)
})
})
sendRelays(url)

View File

@ -4,12 +4,24 @@ import { initDatabase } from '../Functions/DatabaseFunctions'
import SInfo from 'react-native-sensitive-info'
import { AppState, Linking, NativeModules, Platform, StyleSheet } from 'react-native'
import { Text } from 'react-native-paper'
import { type Config } from '../Pages/ConfigPage'
import { imageHostingServices } from '../Constants/Services'
import { randomInt, validNip21 } from '../Functions/NativeFunctions'
import Clipboard from '@react-native-clipboard/clipboard'
import i18next from 'i18next'
export interface Config {
satoshi: 'kebab' | 'sats'
show_public_images: boolean
show_sensitive: boolean
last_notification_seen_at: number
last_pets_at: number
image_hosting_service: string
language: string
relay_coloruring: boolean
long_press_zap: number | undefined
sign_height: boolean
}
export interface AppContextProps {
init: () => void
loadingDb: boolean
@ -45,6 +57,8 @@ export interface AppContextProps {
setPushedTab: (pushedTab: string) => void
qrReader?: string
setQrReader: (qrReader: string | undefined) => void
signHeight: boolean
setSignWithHeight: (signHeight: boolean) => void
}
export interface AppContextProviderProps {
@ -86,6 +100,8 @@ export const initialAppContext: AppContextProps = {
setDisplayNoteDrawer: () => {},
longPressZap: undefined,
setLongPressZap: () => {},
signHeight: false,
setSignWithHeight: () => {}
}
export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.Element => {
@ -114,6 +130,7 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
const [displayUserDrawer, setDisplayUserDrawer] = React.useState<string>()
const [displayNoteDrawer, setDisplayNoteDrawer] = React.useState<string>()
const [pushedTab, setPushedTab] = useState<string>()
const [signHeight, setSignWithHeight] = useState<boolean>(initialAppContext.signHeight)
useEffect(() => {
if (pushedTab) setPushedTab(undefined)
@ -161,6 +178,7 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
setLanguage(config.language ?? initialAppContext.language)
setLongPressZap(config.long_press_zap ?? initialAppContext.longPressZap)
setRelayColouring(config.relay_coloruring ?? initialAppContext.relayColouring)
setSignWithHeight(config.sign_height ?? initialAppContext.signHeight)
} else {
const config: Config = {
show_public_images: initialAppContext.showPublicImages,
@ -172,6 +190,7 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
language: initialAppContext.language,
relay_coloruring: initialAppContext.relayColouring,
long_press_zap: initialAppContext.longPressZap,
sign_height: initialAppContext.signHeight
}
SInfo.setItem('config', JSON.stringify(config), {})
}
@ -249,6 +268,8 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
setDisplayNoteDrawer,
qrReader,
setQrReader,
signHeight,
setSignWithHeight
}}
>
{children}

View File

@ -8,6 +8,8 @@ import { UserContext } from './UserContext'
import { getUnixTime } from 'date-fns'
import { type Event } from '../lib/nostr/Events'
import { randomInt } from '../Functions/NativeFunctions'
import { block } from 'react-native-reanimated'
import axios from 'axios'
export interface RelayPoolContextProps {
relayPoolReady: boolean
@ -24,6 +26,7 @@ export interface RelayPoolContextProps {
sendRelays: (url?: string) => Promise<void>
loadRelays: () => Promise<Relay[]>
createRandomRelays: () => Promise<void>
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>
}
export interface WebsocketEvent {
@ -46,15 +49,15 @@ export const initialRelayPoolContext: RelayPoolContextProps = {
sendRelays: async () => {},
loadRelays: async () => [],
createRandomRelays: async () => {},
sendEvent: async () => null,
}
export const RelayPoolContextProvider = ({
children,
images,
}: RelayPoolContextProviderProps): JSX.Element => {
const { database } = useContext(AppContext)
const { database, signHeight } = useContext(AppContext)
const { publicKey, privateKey } = React.useContext(UserContext)
const [relayPool, setRelayPool] = useState<RelayPool>()
const [relayPoolReady, setRelayPoolReady] = useState<boolean>(false)
const [lastEventId, setLastEventId] = useState<string>('')
@ -62,6 +65,23 @@ export const RelayPoolContextProvider = ({
const [relays, setRelays] = React.useState<Relay[]>([])
const [displayRelayDrawer, setDisplayrelayDrawer] = React.useState<string>()
const sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined> = async (
event,
relayUrl,
) => {
if (signHeight) {
try {
const response = await axios.get("https://mempool.space/api/v1/blocks")
if (response) {
const lastBlock: { id: string, height: number } = response.data[0]
event.tags.push(['bitcoin', lastBlock.id, lastBlock.height.toString()])
}
} catch { }
}
return await relayPool?.sendEvent(event, relayUrl)
}
const sendRelays: (url?: string) => Promise<void> = async (url) => {
if (publicKey && database) {
getActiveRelays(database).then((results) => {
@ -73,7 +93,7 @@ export const RelayPoolContextProvider = ({
pubkey: publicKey,
tags: results.map((relay) => ['r', relay.url, relay.mode ?? '']),
}
url ? relayPool?.sendEvent(event, url) : relayPool?.sendEvent(event)
url ? sendEvent(event, url) : sendEvent(event)
}
})
}
@ -211,6 +231,7 @@ export const RelayPoolContextProvider = ({
sendRelays,
loadRelays,
createRandomRelays,
sendEvent
}}
>
{children}

View File

@ -51,6 +51,10 @@ export const getETags: (event: Event) => string[][] = (event) => {
return event?.tags.filter((tag) => tag[0] === 'e') || []
}
export const getBitcoinTag: (event: Event) => string[][] = (event) => {
return event?.tags.filter((tag) => tag[0] === 'bitcoin') || []
}
export const getPTags: (event: Event) => string[][] = (event) => {
return event?.tags.filter((tag) => tag[0] === 'p') || []
}

View File

@ -6,13 +6,13 @@ import { getList } from '../../DatabaseFunctions/Lists'
import { decrypt, encrypt } from '../../../lib/nostr/Nip04'
export const addBookmarkList: (
relayPool: RelayPool,
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>,
database: QuickSQLiteConnection,
privateKey: string,
publicKey: string,
eventId: string,
publicBookmark: boolean,
) => void = async (relayPool, database, privateKey, publicKey, eventId, publicBookmark) => {
) => void = async (sendEvent, database, privateKey, publicKey, eventId, publicBookmark) => {
if (!eventId || eventId === '') return
const result = await getList(database, 10001, publicKey)
@ -39,15 +39,15 @@ export const addBookmarkList: (
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event)
sendEvent(event)
}
export const addMutedUsersList: (
relayPool: RelayPool,
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>,
database: QuickSQLiteConnection,
publicKey: string,
userId: string,
) => void = async (relayPool, database, publicKey, userId) => {
) => void = async (sendEvent, database, publicKey, userId) => {
if (!userId || userId === '') return
const result = await getList(database, 10000, publicKey)
@ -62,16 +62,16 @@ export const addMutedUsersList: (
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event)
sendEvent(event)
}
export const addList: (
relayPool: RelayPool,
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>,
database: QuickSQLiteConnection,
publicKey: string,
eventId: string,
tag: string,
) => void = async (relayPool, database, publicKey, eventId, tag) => {
) => void = async (sendEvent, database, publicKey, eventId, tag) => {
if (!eventId || eventId === '') return
const result = await getList(database, 30001, publicKey, tag)
@ -86,16 +86,16 @@ export const addList: (
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event)
sendEvent(event)
}
export const removeBookmarkList: (
relayPool: RelayPool,
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>,
database: QuickSQLiteConnection,
privateKey: string,
publicKey: string,
eventId: string,
) => void = async (relayPool, database, privateKey, publicKey, eventId) => {
) => void = async (sendEvent, database, privateKey, publicKey, eventId) => {
if (!eventId || eventId === '') return
const result = await getList(database, 10001, publicKey)
@ -115,16 +115,16 @@ export const removeBookmarkList: (
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event)
sendEvent(event)
}
}
export const removeMutedUsersList: (
relayPool: RelayPool,
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>,
database: QuickSQLiteConnection,
publicKey: string,
userId: string,
) => void = async (relayPool, database, publicKey, userId) => {
) => void = async (sendEvent, database, publicKey, userId) => {
if (!userId || userId === '') return
const result = await getList(database, 10000, publicKey)
@ -138,16 +138,16 @@ export const removeMutedUsersList: (
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event)
sendEvent(event)
}
export const removeList: (
relayPool: RelayPool,
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>,
database: QuickSQLiteConnection,
publicKey: string,
eventId: string,
tag: string,
) => void = async (relayPool, database, publicKey, eventId, tag) => {
) => void = async (sendEvent, database, publicKey, eventId, tag) => {
if (!eventId || eventId === '') return
const result = await getList(database, 30001, publicKey, tag)
@ -161,6 +161,6 @@ export const removeList: (
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event)
sendEvent(event)
}
}

View File

@ -58,10 +58,10 @@ export const getNip05Domain: (nip05: string | undefined) => string | null = (nip
}
export const populatePets: (
relayPool: RelayPool,
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>,
database: QuickSQLiteConnection,
publicKey: string,
) => void = async (relayPool, database, publicKey) => {
) => void = async (sendEvent, database, publicKey) => {
const results = await getUsers(database, { exludeIds: [publicKey], contacts: true })
if (results) {
const event: Event = {
@ -71,15 +71,15 @@ export const populatePets: (
pubkey: publicKey,
tags: usersToTags(results),
}
relayPool?.sendEvent(event)
sendEvent(event)
}
}
export const populateProfile: (
relayPool: RelayPool,
sendEvent: (event: Event, relayUrl?: string) => Promise<Event | null | undefined>,
database: QuickSQLiteConnection,
publicKey: string,
) => void = async (relayPool, database, publicKey) => {
) => void = async (sendEvent, database, publicKey) => {
const result = await getUser(publicKey, database)
if (result) {
const profile = {
@ -95,6 +95,6 @@ export const populateProfile: (
pubkey: publicKey,
tags: usersToTags([result]),
}
relayPool?.sendEvent(event)
sendEvent(event)
}
}

View File

@ -4,21 +4,9 @@ import { FlatList, StyleSheet } from 'react-native'
import { Button, Divider, List, Switch, Text, TextInput, useTheme } from 'react-native-paper'
import SInfo from 'react-native-sensitive-info'
import RBSheet from 'react-native-raw-bottom-sheet'
import { AppContext } from '../../Contexts/AppContext'
import { AppContext, Config } from '../../Contexts/AppContext'
import { imageHostingServices } from '../../Constants/Services'
export interface Config {
satoshi: 'kebab' | 'sats'
show_public_images: boolean
show_sensitive: boolean
last_notification_seen_at: number
last_pets_at: number
image_hosting_service: string
language: string
relay_coloruring: boolean
long_press_zap: number | undefined
}
export const ConfigPage: React.FC = () => {
const theme = useTheme()
const { t } = useTranslation('common')
@ -38,6 +26,8 @@ export const ConfigPage: React.FC = () => {
setRelayColouring,
longPressZap,
setLongPressZap,
signHeight,
setSignWithHeight
} = React.useContext(AppContext)
const bottomSheetSatoshiRef = React.useRef<RBSheet>(null)
const bottomSheetImageHostingRef = React.useRef<RBSheet>(null)
@ -148,6 +138,22 @@ export const ConfigPage: React.FC = () => {
</Text>
)}
/>
<List.Item
title={t('configPage.signHeight')}
right={() => (
<Switch
value={signHeight}
onValueChange={(value) => {
setSignWithHeight(value)
SInfo.getItem('config', {}).then((result) => {
const config: Config = JSON.parse(result)
config.sign_height = value
SInfo.setItem('config', JSON.stringify(config), {})
})
}}
/>
)}
/>
<List.Item title={t('configPage.feed')} />
<Divider />
<List.Item

View File

@ -51,7 +51,7 @@ export const ConversationPage: React.FC<ConversationPageProps> = ({ route }) =>
const theme = useTheme()
const scrollViewRef = useRef<ScrollView>()
const { database, setRefreshBottomBarAt, setDisplayUserDrawer } = useContext(AppContext)
const { relayPool, lastEventId } = useContext(RelayPoolContext)
const { relayPool, lastEventId, sendEvent } = useContext(RelayPoolContext)
const { publicKey, privateKey, name, picture, validNip05 } = useContext(UserContext)
const otherPubKey = useMemo(() => route.params.pubKey, [])
const [pageSize, setPageSize] = useState<number>(initialPageSize)
@ -177,8 +177,7 @@ export const ConversationPage: React.FC<ConversationPageProps> = ({ route }) =>
}
encrypt(privateKey, otherPubKey, input)
.then((encryptedcontent) => {
relayPool
?.sendEvent({
sendEvent({
...event,
content: encryptedcontent,
})

View File

@ -47,7 +47,7 @@ export const GroupPage: React.FC<GroupPageProps> = ({ route }) => {
const initialPageSize = 20
const theme = useTheme()
const { database, setDisplayUserDrawer } = useContext(AppContext)
const { relayPool, lastEventId } = useContext(RelayPoolContext)
const { relayPool, lastEventId, sendEvent } = useContext(RelayPoolContext)
const { publicKey, privateKey, name, picture, validNip05 } = useContext(UserContext)
const [pageSize, setPageSize] = useState<number>(initialPageSize)
const [groupMessages, setGroupMessages] = useState<GroupMessage[]>([])
@ -204,7 +204,7 @@ export const GroupPage: React.FC<GroupPageProps> = ({ route }) => {
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event)
sendEvent(event)
const groupMessage = event as GroupMessage
groupMessage.pending = true
groupMessage.valid_nip05 = validNip05

View File

@ -178,7 +178,7 @@ export const GroupsFeed: React.FC = () => {
pubkey: publicKey,
tags: [],
}
relayPool?.sendEvent(event)
sendEvent(event)
bottomSheetCreateRef.current?.close()
bottomSheetFabActionRef.current?.close()
}

View File

@ -32,7 +32,7 @@ export const ProfileConfigPage: React.FC = () => {
const bottomSheetNip05Ref = React.useRef<RBSheet>(null)
const bottomSheetLud06Ref = React.useRef<RBSheet>(null)
const { database } = useContext(AppContext)
const { relayPool, lastEventId, lastConfirmationtId } = useContext(RelayPoolContext)
const { relayPool, lastEventId, lastConfirmationtId, sendEvent } = useContext(RelayPoolContext)
const {
publicKey,
nPub,
@ -87,8 +87,7 @@ export const ProfileConfigPage: React.FC = () => {
const publishUser: () => Promise<void> = async () => {
return await new Promise<void>((resolve) => {
if (publicKey && relayPool) {
relayPool
?.sendEvent({
sendEvent({
content: JSON.stringify({
name,
about,

View File

@ -19,7 +19,7 @@ interface ProfileCreatePageProps {
export const ProfileCreatePage: React.FC<ProfileCreatePageProps> = ({ navigation }) => {
const { t } = useTranslation('common')
const { setPrivateKey, setUserState, publicKey } = useContext(UserContext)
const { createRandomRelays, relayPool, relays } = useContext(RelayPoolContext)
const { createRandomRelays, sendEvent, relays } = useContext(RelayPoolContext)
const [key, setKey] = useState<string>()
const [inputValue, setInputValue] = useState<string>()
const [keyboardShow, setKeyboardShow] = useState<boolean>(false)
@ -73,7 +73,7 @@ export const ProfileCreatePage: React.FC<ProfileCreatePageProps> = ({ navigation
pubkey: publicKey,
tags: relays.map((relay) => ['r', relay.url, '']),
}
relayPool?.sendEvent(event)
sendEvent(event)
}
if (validConfirmation()) {
setPrivateKey(key)

View File

@ -37,6 +37,7 @@ export const RelaysPage: React.FC = () => {
updateRelayItem,
addRelayItem,
relayPool,
sendEvent,
setDisplayrelayDrawer,
relays,
lastEventId,
@ -144,7 +145,7 @@ export const RelaysPage: React.FC = () => {
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event)
sendEvent(event)
}
bottomSheetPushRef.current?.close()
setShowNotification('listPushed')

View File

@ -27,7 +27,7 @@ export const SendPage: React.FC<SendPageProps> = ({ route }) => {
const theme = useTheme()
const { database } = useContext(AppContext)
const { publicKey } = useContext(UserContext)
const { relayPool, lastConfirmationtId } = useContext(RelayPoolContext)
const { sendEvent, lastConfirmationtId } = useContext(RelayPoolContext)
const { t } = useTranslation('common')
// state
const [content, setContent] = useState<string>('')
@ -104,7 +104,7 @@ export const SendPage: React.FC<SendPageProps> = ({ route }) => {
pubkey: publicKey,
tags,
}
relayPool?.sendEvent(event).catch(() => {})
sendEvent(event).catch(() => {})
}
}