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:
parent
c064b0b40d
commit
e5db949aae
6 changed files with 69 additions and 21 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue