fix(tauri_bindings): Emit swap id with WaitingForBtcDeposit event

This commit is contained in:
binarybaron 2024-08-27 15:23:43 +02:00 committed by binarybaron
parent 88cfd6bc3e
commit de1f77bf80
3 changed files with 32 additions and 13 deletions

View file

@ -18,13 +18,20 @@ export const swapSlice = createSlice({
swap,
action: PayloadAction<TauriSwapProgressEventWrapper>,
) {
// If either:
// 1. No swap is currently running
// 2. The swap ID of the event does not match the current swap ID
//
// Then we create a new swap state object that stores the current and previous events
if (swap.state === null || action.payload.swap_id !== swap.state.swapId) {
console.log("Creating new swap state object");
swap.state = {
curr: action.payload.event,
prev: null,
swapId: action.payload.swap_id,
};
} else {
console.log("Updating existing swap state object");
swap.state.prev = swap.state.curr;
swap.state.curr = action.payload.event;
}