Refactor wallet balance handling and integrate PaymentService for centralized management

- Replaced direct wallet balance computation in Navbar and WalletPage with a centralized totalBalance property from PaymentService, improving code maintainability.
- Updated CreateProductDialog, CreateStoreDialog, and MerchantStore components to utilize PaymentService for retrieving wallet admin and invoice keys, enhancing consistency across the application.
- These changes streamline wallet management and improve the overall architecture of the wallet module.
This commit is contained in:
padreug 2025-09-17 20:23:46 +02:00
parent c064b0b40d
commit e5db949aae
6 changed files with 69 additions and 21 deletions

View file

@ -33,13 +33,12 @@ const { navigation: modularNavigation, userMenuItems } = useModularNavigation()
const navigation = modularNavigation
// Compute total wallet balance
const totalBalance = computed(() => {
if (!auth.currentUser.value?.wallets) return 0
// Get PaymentService from DI for centralized wallet balance
const paymentService = tryInjectService(SERVICE_TOKENS.PAYMENT_SERVICE) as any
return auth.currentUser.value.wallets.reduce((total, wallet) => {
return total + (wallet.balance_msat || 0)
}, 0)
// Use PaymentService for total wallet balance
const totalBalance = computed(() => {
return paymentService?.totalBalance || 0
})
// Try to get chat service from DI (may not be available if chat module not loaded)