Refactor AuthService and market components for improved functionality and error handling
- Integrate LNbits API for authentication in AuthService, replacing token management with direct API calls for user data. - Enhance login and registration processes to utilize the new API, improving user experience and error handling. - Update market components to include detailed logging and fallback mechanisms for offline scenarios, ensuring better resilience during market data loading. - Refactor market preloader to handle connection timeouts and provide sample data as a fallback, enhancing user experience in offline mode.
This commit is contained in:
parent
daa9656680
commit
55e99e002d
5 changed files with 178 additions and 63 deletions
|
|
@ -404,16 +404,29 @@ export class ChatService {
|
|||
console.log('Loading message history for', peerPubkeys.length, 'peers')
|
||||
|
||||
// Query historical messages (kind 4) to/from known peers
|
||||
const events = await relayHub.queryEvents([
|
||||
// We need separate queries for sent vs received messages due to different tagging
|
||||
const receivedEvents = await relayHub.queryEvents([
|
||||
{
|
||||
kinds: [4],
|
||||
authors: [userPubkey, ...peerPubkeys], // Messages from us or peers
|
||||
'#p': [userPubkey], // Messages tagged with our pubkey
|
||||
limit: 100 // Limit to last 100 messages per conversation
|
||||
authors: peerPubkeys, // Messages from peers
|
||||
'#p': [userPubkey], // Messages tagged to us
|
||||
limit: 100
|
||||
}
|
||||
])
|
||||
|
||||
console.log('Found', events.length, 'historical messages')
|
||||
const sentEvents = await relayHub.queryEvents([
|
||||
{
|
||||
kinds: [4],
|
||||
authors: [userPubkey], // Messages from us
|
||||
'#p': peerPubkeys, // Messages tagged to peers
|
||||
limit: 100
|
||||
}
|
||||
])
|
||||
|
||||
const events = [...receivedEvents, ...sentEvents]
|
||||
.sort((a, b) => a.created_at - b.created_at) // Sort by timestamp
|
||||
|
||||
console.log('Found', events.length, 'historical messages:', receivedEvents.length, 'received,', sentEvents.length, 'sent')
|
||||
|
||||
// Process historical messages
|
||||
for (const event of events) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue