mirror of
https://github.com/KoalaSat/nostros.git
synced 2024-09-29 06:30:47 +00:00
Bug Fix 2
This commit is contained in:
parent
e7830f85ce
commit
25f0b4686f
@ -6,6 +6,7 @@ import Icon from 'react-native-vector-icons/FontAwesome5'
|
|||||||
import { Event, EventKind } from '../../lib/nostr/Events'
|
import { Event, EventKind } from '../../lib/nostr/Events'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import {
|
import {
|
||||||
|
getUser,
|
||||||
getUsers,
|
getUsers,
|
||||||
insertUserPets,
|
insertUserPets,
|
||||||
updateUserContact,
|
updateUserContact,
|
||||||
@ -58,7 +59,7 @@ export const ContactsPage: React.FC = () => {
|
|||||||
|
|
||||||
const subscribeContacts: () => void = async () => {
|
const subscribeContacts: () => void = async () => {
|
||||||
relayPool?.unsubscribeAll()
|
relayPool?.unsubscribeAll()
|
||||||
relayPool?.on('event', 'contacts', (relay: Relay, _subId?: string, event?: Event) => {
|
relayPool?.on('event', 'contacts', async (relay: Relay, _subId?: string, event?: Event) => {
|
||||||
console.log('CONTACTS PAGE EVENT =======>', relay.url, event)
|
console.log('CONTACTS PAGE EVENT =======>', relay.url, event)
|
||||||
if (database && event?.id && publicKey && event.kind === EventKind.petNames) {
|
if (database && event?.id && publicKey && event.kind === EventKind.petNames) {
|
||||||
if (event.pubkey === publicKey) {
|
if (event.pubkey === publicKey) {
|
||||||
@ -66,9 +67,17 @@ export const ContactsPage: React.FC = () => {
|
|||||||
relayPool?.removeOn('event', 'contacts')
|
relayPool?.removeOn('event', 'contacts')
|
||||||
} else {
|
} else {
|
||||||
const isFollower = event.tags.some((tag) => tag[1] === publicKey)
|
const isFollower = event.tags.some((tag) => tag[1] === publicKey)
|
||||||
updateUserFollower(event.pubkey, database, isFollower).then(() => {
|
await updateUserFollower(event.pubkey, database, isFollower)
|
||||||
setLastEventId(event?.id ?? '')
|
setLastEventId(event?.id ?? '')
|
||||||
})
|
if (isFollower) {
|
||||||
|
const user = await getUser(event.pubkey, database)
|
||||||
|
if (!user?.name && user?.id) {
|
||||||
|
relayPool?.subscribe('main-channel', {
|
||||||
|
kinds: [EventKind.meta],
|
||||||
|
authors: [user.id],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -84,12 +93,6 @@ export const ContactsPage: React.FC = () => {
|
|||||||
'#p': [publicKey],
|
'#p': [publicKey],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (users && users.length > 0) {
|
|
||||||
relayPool?.subscribe('main-channel', {
|
|
||||||
kinds: [EventKind.meta],
|
|
||||||
authors: users?.map((user) => user.id),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import NoteCard from '../NoteCard'
|
|||||||
import { RelayPoolContext } from '../../Contexts/RelayPoolContext'
|
import { RelayPoolContext } from '../../Contexts/RelayPoolContext'
|
||||||
import {
|
import {
|
||||||
getUser,
|
getUser,
|
||||||
removeContact,
|
|
||||||
User,
|
User,
|
||||||
updateUserFollower,
|
updateUserFollower,
|
||||||
updateUserContact,
|
updateUserContact,
|
||||||
@ -157,7 +156,7 @@ export const ProfilePage: React.FC = () => {
|
|||||||
|
|
||||||
const removeAuthor: () => void = () => {
|
const removeAuthor: () => void = () => {
|
||||||
if (relayPool && database && publicKey) {
|
if (relayPool && database && publicKey) {
|
||||||
removeContact(userId, database).then(() => {
|
updateUserContact(userId, database, false).then(() => {
|
||||||
populatePets(relayPool, database, publicKey)
|
populatePets(relayPool, database, publicKey)
|
||||||
setIsContact(false)
|
setIsContact(false)
|
||||||
})
|
})
|
||||||
|
@ -106,15 +106,6 @@ export const getUser: (pubkey: string, db: QuickSQLiteConnection) => Promise<Use
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeContact: (
|
|
||||||
pubkey: string,
|
|
||||||
db: QuickSQLiteConnection,
|
|
||||||
) => Promise<QueryResult> = async (pubkey, db) => {
|
|
||||||
const userQuery = `UPDATE nostros_users SET contact = 0 WHERE id = ?`
|
|
||||||
|
|
||||||
return db.execute(userQuery, [pubkey])
|
|
||||||
}
|
|
||||||
|
|
||||||
export const addUser: (pubKey: string, db: QuickSQLiteConnection) => Promise<QueryResult> = async (
|
export const addUser: (pubKey: string, db: QuickSQLiteConnection) => Promise<QueryResult> = async (
|
||||||
pubKey,
|
pubKey,
|
||||||
db,
|
db,
|
||||||
|
Loading…
Reference in New Issue
Block a user