feat: Integrate Nostr chat preloader for improved chat data handling
- Introduce a new composable, useNostrChatPreloader, to manage chat data preloading, including peer loading and subscription for notifications. - Update ChatComponent to utilize the preloader, ensuring chat data is ready before connecting. - Enhance Navbar to display unread message counts with notification badges for better user experience. - Refactor App.vue to trigger both market and chat preloading upon successful login, streamlining the user experience.
This commit is contained in:
parent
b0101915c7
commit
855a003962
4 changed files with 233 additions and 133 deletions
21
src/App.vue
21
src/App.vue
|
|
@ -8,13 +8,15 @@ import { Toaster } from '@/components/ui/sonner'
|
|||
import 'vue-sonner/style.css'
|
||||
import { auth } from '@/composables/useAuth'
|
||||
import { useMarketPreloader } from '@/composables/useMarketPreloader'
|
||||
import { useNostrChatPreloader } from '@/composables/useNostrChatPreloader'
|
||||
import { toast } from 'vue-sonner'
|
||||
|
||||
const route = useRoute()
|
||||
const showLoginDialog = ref(false)
|
||||
|
||||
// Initialize market preloader
|
||||
// Initialize preloaders
|
||||
const marketPreloader = useMarketPreloader()
|
||||
const chatPreloader = useNostrChatPreloader()
|
||||
|
||||
// Hide navbar on login page
|
||||
const showNavbar = computed(() => {
|
||||
|
|
@ -25,8 +27,9 @@ function handleLoginSuccess() {
|
|||
showLoginDialog.value = false
|
||||
toast.success('Welcome back!')
|
||||
|
||||
// Trigger market preloading after successful login
|
||||
// Trigger preloading after successful login
|
||||
marketPreloader.preloadMarket()
|
||||
chatPreloader.preloadChat()
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
@ -38,11 +41,17 @@ onMounted(async () => {
|
|||
}
|
||||
})
|
||||
|
||||
// Watch for authentication changes and trigger market preloading
|
||||
// Watch for authentication changes and trigger preloading
|
||||
watch(() => auth.isAuthenticated.value, (isAuthenticated) => {
|
||||
if (isAuthenticated && !marketPreloader.isPreloaded.value) {
|
||||
console.log('User authenticated, triggering market preload...')
|
||||
marketPreloader.preloadMarket()
|
||||
if (isAuthenticated) {
|
||||
if (!marketPreloader.isPreloaded.value) {
|
||||
console.log('User authenticated, triggering market preload...')
|
||||
marketPreloader.preloadMarket()
|
||||
}
|
||||
if (!chatPreloader.isPreloaded.value) {
|
||||
console.log('User authenticated, triggering chat preload...')
|
||||
chatPreloader.preloadChat()
|
||||
}
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue