refactor(gui): seperate get info and get timelock to speed up display of swaps (#661)

* refactor(gui): seperate get info and get timelock to speed up display of swaps

* progress

* progress

* remove unused function useSwapInfoWithTimelock

* use GetSwapTimelockArgs and GetSwapTimelockResponse types
This commit is contained in:
Mohan 2025-11-02 19:41:21 +01:00 committed by GitHub
parent 0fec5d556d
commit 33662b0a06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 333 additions and 203 deletions

View file

@ -21,6 +21,7 @@ import {
import {
checkContextStatus,
getSwapInfo,
getSwapTimelock,
initializeContext,
listSellersAtRendezvousPoint,
refreshApprovals,
@ -122,12 +123,32 @@ listen<TauriEvent>(TAURI_UNIFIED_EVENT_CHANNEL_NAME, (event) => {
break;
case "SwapDatabaseStateUpdate":
getSwapInfo(eventData.swap_id);
getSwapInfo(eventData.swap_id).catch((error) => {
logger.debug(
`Failed to fetch swap info for swap ${eventData.swap_id}: ${error}`,
);
});
getSwapTimelock(eventData.swap_id).catch((error) => {
logger.debug(
`Failed to fetch timelock for swap ${eventData.swap_id}: ${error}`,
);
});
// This is ugly but it's the best we can do for now
// Sometimes we are too quick to fetch the swap info and the new state is not yet reflected
// in the database. So we wait a bit before fetching the new state
setTimeout(() => getSwapInfo(eventData.swap_id), 3000);
setTimeout(() => {
getSwapInfo(eventData.swap_id).catch((error) => {
logger.debug(
`Failed to fetch swap info for swap ${eventData.swap_id}: ${error}`,
);
});
getSwapTimelock(eventData.swap_id).catch((error) => {
logger.debug(
`Failed to fetch timelock for swap ${eventData.swap_id}: ${error}`,
);
});
}, 3000);
break;
case "TimelockChange":