mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-25 18:26:28 -05:00
feat(tauri): Initialize Context in background (#59)
This PR does the following: - The Context (including Bitcoin wallet, Monero wallet, ...) is initialized in the background. This allows the window to be displayed instantly upon startup. - Host sends events to Guest about progress of Context initialization. Those events are used to display an alert in the navigation bar. - If a Tauri command is invoked which requires the Context to be available, an error will be returned - As soon as the Context becomes available the `Guest` requests the history and Bitcoin balance - Re-enables Material UI animations
This commit is contained in:
parent
792fbbf746
commit
e4141c763b
17 changed files with 369 additions and 191 deletions
|
|
@ -9,11 +9,16 @@ import {
|
|||
ResumeSwapArgs,
|
||||
ResumeSwapResponse,
|
||||
SuspendCurrentSwapResponse,
|
||||
TauriContextStatusEvent,
|
||||
TauriSwapProgressEventWrapper,
|
||||
WithdrawBtcArgs,
|
||||
WithdrawBtcResponse,
|
||||
} from "models/tauriModel";
|
||||
import { rpcSetBalance, rpcSetSwapInfo } from "store/features/rpcSlice";
|
||||
import {
|
||||
contextStatusEventReceived,
|
||||
rpcSetBalance,
|
||||
rpcSetSwapInfo,
|
||||
} from "store/features/rpcSlice";
|
||||
import { swapTauriEventReceived } from "store/features/swapSlice";
|
||||
import { store } from "./store/storeRenderer";
|
||||
import { Provider } from "models/apiModel";
|
||||
|
|
@ -24,6 +29,11 @@ export async function initEventListeners() {
|
|||
console.log("Received swap progress event", event.payload);
|
||||
store.dispatch(swapTauriEventReceived(event.payload));
|
||||
});
|
||||
|
||||
listen<TauriContextStatusEvent>("context-init-progress-update", (event) => {
|
||||
console.log("Received context init progress event", event.payload);
|
||||
store.dispatch(contextStatusEventReceived(event.payload));
|
||||
});
|
||||
}
|
||||
|
||||
async function invoke<ARGS, RESPONSE>(
|
||||
|
|
@ -47,7 +57,7 @@ export async function checkBitcoinBalance() {
|
|||
store.dispatch(rpcSetBalance(response.balance));
|
||||
}
|
||||
|
||||
export async function getRawSwapInfos() {
|
||||
export async function getAllSwapInfos() {
|
||||
const response =
|
||||
await invokeNoArgs<GetSwapInfoResponse[]>("get_swap_infos_all");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue