Refactor chat and market modules for improved integration and maintainability
- Remove deprecated Nostr chat and relay hub components, transitioning to a modular chat service for better encapsulation. - Update App.vue and Navbar.vue to utilize the new chat module, enhancing user experience with automatic peer management. - Simplify event handling and connection logic in ChatComponent.vue, ensuring compatibility with the new chat service architecture. - Adjust market settings and order history components to reflect changes in the chat module, improving overall coherence in the application structure. - Clean up unused imports and streamline configuration access for better performance and maintainability.
This commit is contained in:
parent
63de083909
commit
17c07c37a0
17 changed files with 63 additions and 2222 deletions
38
src/App.vue
38
src/App.vue
|
|
@ -7,9 +7,7 @@ import LoginDialog from '@/components/auth/LoginDialog.vue'
|
|||
import { Toaster } from '@/components/ui/sonner'
|
||||
import 'vue-sonner/style.css'
|
||||
import { useMarketPreloader } from '@/composables/useMarketPreloader'
|
||||
import { nostrChat } from '@/composables/useNostrChat'
|
||||
import { auth } from '@/composables/useAuth'
|
||||
import { relayHubComposable } from '@/composables/useRelayHub'
|
||||
import { toast } from 'vue-sonner'
|
||||
|
||||
const route = useRoute()
|
||||
|
|
@ -18,8 +16,7 @@ const showLoginDialog = ref(false)
|
|||
// Initialize preloader
|
||||
const marketPreloader = useMarketPreloader()
|
||||
|
||||
// Initialize relay hub
|
||||
const relayHub = relayHubComposable
|
||||
// Relay hub initialization is now handled by the base module
|
||||
|
||||
// Hide navbar on login page
|
||||
const showNavbar = computed(() => {
|
||||
|
|
@ -33,18 +30,7 @@ async function handleLoginSuccess() {
|
|||
// Trigger preloading after successful login
|
||||
marketPreloader.preloadMarket()
|
||||
|
||||
// Connect to chat
|
||||
if (!nostrChat.isConnected.value) {
|
||||
try {
|
||||
await nostrChat.connect()
|
||||
|
||||
// Load peers and subscribe to all for notifications
|
||||
const peers = await nostrChat.loadPeers()
|
||||
await nostrChat.subscribeToAllPeersForNotifications(peers)
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize chat:', error)
|
||||
}
|
||||
}
|
||||
// Chat initialization is now handled by the chat module
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
@ -55,12 +41,7 @@ onMounted(async () => {
|
|||
console.error('Failed to initialize authentication:', error)
|
||||
}
|
||||
|
||||
// Initialize relay hub
|
||||
try {
|
||||
await relayHub.initialize()
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize relay hub:', error)
|
||||
}
|
||||
// Relay hub initialization is handled by the base module
|
||||
})
|
||||
|
||||
// Watch for authentication changes and trigger preloading
|
||||
|
|
@ -70,18 +51,7 @@ watch(() => auth.isAuthenticated.value, async (isAuthenticated) => {
|
|||
console.log('User authenticated, triggering market preload...')
|
||||
marketPreloader.preloadMarket()
|
||||
}
|
||||
if (!nostrChat.isConnected.value) {
|
||||
console.log('User authenticated, connecting to chat...')
|
||||
try {
|
||||
await nostrChat.connect()
|
||||
|
||||
// Load peers and subscribe to all for notifications
|
||||
const peers = await nostrChat.loadPeers()
|
||||
await nostrChat.subscribeToAllPeersForNotifications(peers)
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize chat:', error)
|
||||
}
|
||||
}
|
||||
// Chat connection is now handled by the chat module automatically
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue