Fixing merge conflicts

This commit is contained in:
Chris Troutner
2025-11-05 07:44:43 -08:00
5 changed files with 51 additions and 29 deletions
-3
View File
@@ -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)
+1 -1
View File
@@ -34,7 +34,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
View File
@@ -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
@@ -245,9 +242,7 @@ function useAppState () {
startChannelChat,
setStartChannelChat,
asyncBackGroundInitState,
updateBackGroundInitState,
deletedChats,
setDeletedChats
updateBackGroundInitState
}
}
-19
View File
@@ -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) {
+49
View File
@@ -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 }) {
@@ -20,11 +23,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
@@ -115,6 +123,12 @@ export default class NostrQueries {
let feeds = await this.restClient.queryEvents(subId, filter)
// Filter out deleted posts
feeds = feeds.filter((ev) => {
const isDeleted = this.deletedPosts.find((val) => { return val.eventId === ev.id })
return !isDeleted
})
// Remove duplicated feeds
feeds = feeds.filter((val, i, list) => {
const existingIndex = list.findIndex(value => value.id === val.id)
@@ -326,4 +340,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
}
}
}