From 22048c678f29a4fc31fa52aadae8061f5f0ab2af Mon Sep 17 00:00:00 2001 From: Ramadhan Sjamsani Date: Mon, 1 Jun 2026 22:27:26 +0800 Subject: [PATCH] fix(payment): autoDispose payment catalog so CC edits reflect without app restart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit paymentCatalogProvider was a plain FutureProvider, which Riverpod caches for the whole app session — so control-center enable/disable/create of payment methods only showed up after an app restart. Backend was already correct (every mutator calls invalidatePaymentCatalog). Switch to FutureProvider.autoDispose so the catalog is dropped when the payment page is popped and re-fetched on re-open. Only watched by the payment method screen. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../payment/state/payment_catalog_provider.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client_app/lib/features/payment/state/payment_catalog_provider.dart b/client_app/lib/features/payment/state/payment_catalog_provider.dart index 06db942..701c378 100644 --- a/client_app/lib/features/payment/state/payment_catalog_provider.dart +++ b/client_app/lib/features/payment/state/payment_catalog_provider.dart @@ -106,7 +106,15 @@ const PaymentCatalog kFallbackPaymentCatalog = _FallbackCatalog(); /// App-facing catalog. Calls `GET /api/client/payment-methods`; on 5xx or /// network error returns [kFallbackPaymentCatalog] so checkout never /// hard-fails. See `requirement/phase5-payment-catalog-plan.md` §5. -final paymentCatalogProvider = FutureProvider((ref) async { +/// +/// `autoDispose`: a plain FutureProvider caches its result for the whole app +/// session, so control-center edits to payment methods (enable/disable/create) +/// only showed up after an app restart. autoDispose drops the cached catalog +/// once the payment screen is popped (no listeners), so re-opening the payment +/// page re-fetches the now-current catalog from the backend (whose own cache is +/// invalidated on every mutation). +final paymentCatalogProvider = + FutureProvider.autoDispose((ref) async { final api = ref.read(apiClientProvider); try { final res = await api.get('/api/client/payment-methods');