mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex-taker-v2.git
synced 2026-09-21 16:52:01 -07:00
minor code readability edits
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@
|
||||
"@fortawesome/free-regular-svg-icons": "6.7.2",
|
||||
"@fortawesome/free-solid-svg-icons": "6.7.2",
|
||||
"@fortawesome/react-fontawesome": "0.2.2",
|
||||
"@noble/hashes": "^1.8.0",
|
||||
"@noble/hashes": "1.8.0",
|
||||
"axios": "0.27.2",
|
||||
"bch-dex-lib": "2.2.0",
|
||||
"bch-message-lib": "2.2.1",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import React, { useCallback, useEffect, useState, useRef } from 'react'
|
||||
import { Container, Row, Col } from 'react-bootstrap'
|
||||
import { RelayPool } from 'nostr'
|
||||
|
||||
// Local libraries
|
||||
import ChatSidebar from './chat-sidebar'
|
||||
import ChatMain from './chat-main'
|
||||
@@ -28,12 +29,13 @@ function NostrChat (props) {
|
||||
try {
|
||||
// Update messages list
|
||||
setMessages(current => {
|
||||
const exist = current.find(val => val.id === msg.id)
|
||||
// ignore existing messages
|
||||
const exist = current.find(val => val.id === msg.id)
|
||||
if (exist) return current
|
||||
|
||||
const newMsgs = [...current]
|
||||
newMsgs.push(msg)
|
||||
|
||||
// Sort messages by timestamp
|
||||
newMsgs.sort((a, b) => b.created_at - a.created_at)
|
||||
return newMsgs.reverse()
|
||||
@@ -45,9 +47,11 @@ function NostrChat (props) {
|
||||
if (existProfile) {
|
||||
return
|
||||
}
|
||||
// Fech profile.
|
||||
|
||||
// Fetch profile.
|
||||
let profile = await appData.nostrQueries.getProfile(pubKey)
|
||||
if (!profile) profile = { name: pubKey }
|
||||
|
||||
// Update profiles state
|
||||
setProfiles(currentProfiles => {
|
||||
const newProfiles = { ...currentProfiles }
|
||||
|
||||
Reference in New Issue
Block a user