Implement LNbits integration in AuthService and enhance ChatComponent for improved user experience
- Refactor AuthService to integrate LNbits authentication, including fetching user data from the API and handling token validation. - Update ChatComponent to reflect changes in peer management, replacing user_id with pubkey and username with name for better clarity. - Enhance connection status indicators in ChatComponent for improved user feedback during chat initialization.
This commit is contained in:
parent
d33d2abf8a
commit
daa9656680
4 changed files with 421 additions and 129 deletions
|
|
@ -20,6 +20,7 @@ export function useChat() {
|
|||
// Computed properties
|
||||
const peers = computed(() => chatService.allPeers.value)
|
||||
const totalUnreadCount = computed(() => chatService.totalUnreadCount.value)
|
||||
const isReady = computed(() => chatService.isReady.value)
|
||||
|
||||
const currentMessages = computed(() => {
|
||||
return selectedPeer.value ? chatService.getMessages(selectedPeer.value) : []
|
||||
|
|
@ -61,6 +62,19 @@ export function useChat() {
|
|||
chatService.markAsRead(peerPubkey)
|
||||
}
|
||||
|
||||
const refreshPeers = async () => {
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
await chatService.refreshPeers()
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to refresh peers'
|
||||
console.error('Failed to refresh peers:', err)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
// State
|
||||
selectedPeer,
|
||||
|
|
@ -70,6 +84,7 @@ export function useChat() {
|
|||
// Computed
|
||||
peers,
|
||||
totalUnreadCount,
|
||||
isReady,
|
||||
currentMessages,
|
||||
currentPeer,
|
||||
|
||||
|
|
@ -77,6 +92,7 @@ export function useChat() {
|
|||
selectPeer,
|
||||
sendMessage,
|
||||
addPeer,
|
||||
markAsRead
|
||||
markAsRead,
|
||||
refreshPeers
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue