minor code readability edits

This commit is contained in:
Chris Troutner
2025-08-28 08:13:44 -07:00
parent 9055cbcc5d
commit af27967415
2 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -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 -2
View File
@@ -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 }