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 | |
|---|---|---|---|
|
|
9f7b11fbc4 | ||
|
|
9f6c0d3fc7 | ||
|
|
dfb0bca2ec |
@@ -155,9 +155,6 @@ function App (props) {
|
||||
const nostrLib = asyncLoad.getNostrLib({ bchWallet: walletTemp })
|
||||
appData.setNostr(nostrLib)
|
||||
|
||||
const deletedChats = await asyncLoad.fetchDeletedChats()
|
||||
appData.setDeletedChats(deletedChats)
|
||||
|
||||
// Update state
|
||||
appData.setShowStartModal(false)
|
||||
appData.setDenyClose(false)
|
||||
|
||||
@@ -30,7 +30,7 @@ function NostrChat (props) {
|
||||
const [selectedChannel, setSelectedChannel] = useState(null)
|
||||
const [selectedChannelIsDm, setSelectedChannelIsDm] = useState(false)
|
||||
|
||||
const [deletedChats] = useState(appData.deletedChats)
|
||||
const [deletedChats] = useState(appData.nostrQueries.deletedChats)
|
||||
|
||||
const profilesRef = useRef({})
|
||||
const dmChannelsRef = useRef([])
|
||||
|
||||
+1
-6
@@ -47,9 +47,6 @@ function useAppState () {
|
||||
const [denyClose, setDenyClose] = useState(false)
|
||||
const [isSingleView, setIsSingleView] = useState(false)
|
||||
|
||||
// Deleted nostr chats.
|
||||
const [deletedChats, setDeletedChats] = useState([])
|
||||
|
||||
// Background process state
|
||||
const [asyncBackGroundInitState, setAsyncBackGroundInitState] = useState({
|
||||
bchInitLoaded: false, slpInitLoaded: false, asyncBackgroundFinished: false
|
||||
@@ -241,9 +238,7 @@ function useAppState () {
|
||||
startChannelChat,
|
||||
setStartChannelChat,
|
||||
asyncBackGroundInitState,
|
||||
updateBackGroundInitState,
|
||||
deletedChats,
|
||||
setDeletedChats
|
||||
updateBackGroundInitState
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ import { base58_to_binary as base58ToBinary } from 'base58-js'
|
||||
import { bytesToHex } from '@noble/hashes/utils' // already an installed dependency
|
||||
import { getPublicKey } from 'nostr-tools/pure'
|
||||
import * as nip19 from 'nostr-tools/nip19'
|
||||
import config from '../config'
|
||||
|
||||
const SERVER = `${config.dexServer}/`
|
||||
|
||||
class AsyncLoad {
|
||||
constructor () {
|
||||
@@ -336,22 +333,6 @@ class AsyncLoad {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Get all deleted chats
|
||||
async fetchDeletedChats () {
|
||||
try {
|
||||
const options = {
|
||||
method: 'GET',
|
||||
url: `${SERVER}nostr/deletedChat`
|
||||
}
|
||||
const result = await axios.request(options)
|
||||
const { deletedChats } = result.data
|
||||
return deletedChats
|
||||
} catch (error) {
|
||||
console.error('Error deletedChats: ', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sleep (ms) {
|
||||
|
||||
@@ -7,6 +7,9 @@ import * as nip19 from 'nostr-tools/nip19'
|
||||
import { nip04 } from 'nostr-tools'
|
||||
import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency
|
||||
import axios from 'axios'
|
||||
import config from '../config'
|
||||
|
||||
const SERVER = `${config.dexServer}/`
|
||||
|
||||
export default class NostrQueries {
|
||||
constructor ({ relays }) {
|
||||
@@ -16,11 +19,16 @@ export default class NostrQueries {
|
||||
this.loadedChannelsInfo = {}
|
||||
this.blackList = []
|
||||
this.blackListFetched = false
|
||||
|
||||
this.deletedChats = []
|
||||
this.deletedPosts = []
|
||||
}
|
||||
|
||||
async start () {
|
||||
try {
|
||||
await this.getBlackList()
|
||||
await this.fetchDeletedChats()
|
||||
await this.fetchDeletedPosts()
|
||||
} catch (error) {
|
||||
console.error('NostrQueries.start() error : ', error.message)
|
||||
throw error
|
||||
@@ -182,7 +190,9 @@ export default class NostrQueries {
|
||||
|
||||
pool.on('event', (relay, subId, ev) => {
|
||||
console.log('post retrieved from ', relay.url, ev.sig)
|
||||
list = [...list, ev]
|
||||
const isDeleted = this.deletedPosts.find((val) => { return val.eventId === ev.id })
|
||||
|
||||
if (!isDeleted) list = [...list, ev]
|
||||
})
|
||||
pool.on('error', (relay) => {
|
||||
relay.close()
|
||||
@@ -506,4 +516,39 @@ export default class NostrQueries {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Get all deleted chats
|
||||
async fetchDeletedChats () {
|
||||
try {
|
||||
const options = {
|
||||
method: 'GET',
|
||||
url: `${SERVER}nostr/deletedChat`
|
||||
}
|
||||
const result = await axios.request(options)
|
||||
const { deletedChats } = result.data
|
||||
this.deletedChats = deletedChats
|
||||
} catch (error) {
|
||||
console.error('Error fetchDeletedChats: ', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Get all deleted posts
|
||||
async fetchDeletedPosts () {
|
||||
try {
|
||||
const options = {
|
||||
method: 'GET',
|
||||
url: `${SERVER}nostr/deletedPost`
|
||||
}
|
||||
const result = await axios.request(options)
|
||||
console.log('result', result)
|
||||
const { deletedPosts } = result.data
|
||||
console.log('deletedPosts', deletedPosts)
|
||||
|
||||
this.deletedPosts = deletedPosts
|
||||
} catch (error) {
|
||||
console.error('Error fetchDeletedPosts: ', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user