Refactor PaymentService and related components for improved state management

- Reset payment state on initialization in PaymentService to prevent stuck states.
- Introduce forceResetPaymentState method for debugging purposes.
- Update useTicketPurchase and useLightningPayment composables to reflect changes in computed properties for better state handling.
- Ensure OrderHistory component resets payment state on mount to enhance user experience.
This commit is contained in:
padreug 2025-09-05 16:18:13 +02:00
parent ef7333e68e
commit e8b9f04494
4 changed files with 28 additions and 8 deletions

View file

@ -259,6 +259,7 @@ import type { OrderStatus } from '@/stores/market'
const router = useRouter()
const marketStore = useMarketStore()
const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB) as any
const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE) as any
const { handlePayment, isPayingWithWallet, hasWalletWithBalance } = useLightningPayment()
// const orderEvents = useOrderEvents() // TODO: Move to market module
@ -483,6 +484,11 @@ const navigateToMarket = () => router.push('/market')
// Load orders on mount
onMounted(() => {
// Reset payment state to prevent stuck "Paying..." buttons (safety measure)
if (paymentService?.forceResetPaymentState) {
paymentService.forceResetPaymentState()
}
// Orders are already loaded in the market store
console.log('Order History component loaded with', allOrders.value.length, 'orders')
console.log('Market store orders:', marketStore.orders)
@ -525,4 +531,5 @@ watch(
},
{ immediate: true }
)
</script>