Fixes loading/error/refresh-state gaps across the Enable Banking (PSD2) surfaces: - Delete the dead post-OAuth bank_connected sync flow + 9 orphaned i18n keys. - Surface fetch failures instead of empty/false-healthy states (settings panel error card, BankSelector non-OK guard, chip hidden on error). - Stop the full-panel spinner flash on refetch; clear the spinner in finally. - Client-side sync/backfill timeouts + live elapsed counter with a grace-period unlock so a slow bank can't trap the modal. - Broadcast a bank-sync signal so the transactions chip refetches after a manual sync. - Consolidate the import page onto the shared banking panel (also removes the core -> @/extensions import-rule violation) and standardize spinners. - Surface previously silent chart/fiscal-year fetch failures in the account picker. - Review fixes: cancellation guard on the deferred bank_error microtask; key the sync-progress dialog per attempt to reset its elapsed timer.
27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
/**
|
|
* Cross-component signal that a bank sync (or reconnect) just changed
|
|
* `bank_connections` rows or imported new transactions.
|
|
*
|
|
* Several surfaces render bank-sync status from a client-side fetch on mount
|
|
* (the transactions-page status chip, the "since last visit" pill, the banking
|
|
* settings panel). Without a shared signal they show stale data until a hard
|
|
* reload: e.g. a manual "Sync now" pulls fresh rows but the neighbouring chip
|
|
* keeps showing the old "synced 2d ago" until the page is reloaded.
|
|
*
|
|
* Sync entry points call `notifyBankSyncUpdated()` on success; status surfaces
|
|
* subscribe with `onBankSyncUpdated()` and refetch. This is a browser-only
|
|
* CustomEvent, so it is a no-op during SSR.
|
|
*/
|
|
export const BANK_SYNC_UPDATED_EVENT = 'gnubok:bank-sync-updated'
|
|
|
|
export function notifyBankSyncUpdated(): void {
|
|
if (typeof window === 'undefined') return
|
|
window.dispatchEvent(new Event(BANK_SYNC_UPDATED_EVENT))
|
|
}
|
|
|
|
export function onBankSyncUpdated(handler: () => void): () => void {
|
|
if (typeof window === 'undefined') return () => {}
|
|
window.addEventListener(BANK_SYNC_UPDATED_EVENT, handler)
|
|
return () => window.removeEventListener(BANK_SYNC_UPDATED_EVENT, handler)
|
|
}
|