| … | … | @@ -2929,11 +2929,25 @@ async function executeSend() { |
| 2929 | 2929 | // console.log('Notification failed (non-critical):', notifErr.message) |
| 2930 | 2930 | // } |
| 2931 | 2931 | |
| 2932 | | // Refresh balances and transactions |
| 2933 | | setTimeout(() => { |
| 2932 | // Sync transaction from blockchain, then refresh balances and display |
| 2933 | setTimeout(async () => { |
| 2934 | // First sync from blockchain to fetch the new transaction |
| 2935 | try { |
| 2936 | const syncRes = await authFetch(`/api/transactions/sync`, { |
| 2937 | method: 'POST', |
| 2938 | headers: { 'Content-Type': 'application/json' }, |
| 2939 | body: JSON.stringify({ chain: currentSendChain }) |
| 2940 | }) |
| 2941 | const syncData = await syncRes.json() |
| 2942 | console.log('Auto-sync after send:', syncData) |
| 2943 | } catch (syncErr) { |
| 2944 | console.warn('Auto-sync failed (non-critical):', syncErr.message) |
| 2945 | } |
| 2946 | |
| 2947 | // Then refresh UI |
| 2934 | 2948 | loadCurrentBalance() |
| 2935 | 2949 | loadTransactions() |
| 2936 | | }, 1000) |
| 2950 | }, 2000) // Wait 2 seconds for transaction to propagate |
| 2937 | 2951 | |
| 2938 | 2952 | } catch (err) { |
| 2939 | 2953 | console.error('Send error:', err) |