mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-21 11:25:50 -05:00
feat(tauri, gui): Send event on changes to details, timelocks and tx_lock confirmations (#100)
- Send event when new swap state is inserated into database. The event only has the `swap_id` attached. The frontend then sends a request to the `get_swap_info` command to retrieve the updated version - Send event when the Bitcoin lock transaction gets a new confirmation - A new `watcher` daemon runs contineously and sends an event when the timelock updated. The event has the the `swap_id` and the timelock attached - Display logs on `ProcessExitedPage` (if swap was stopped prematurely) - Rename `CliLogEmittedEvent` to `TauriLogEvent` - Apply env_filter to tracing terminal writer to silence logging from other crates - Add `.env.*` files in `src-gui` to `.gitingore` Closes #93 and #12
This commit is contained in:
parent
e6dc7ddcef
commit
8f33fe5b41
28 changed files with 429 additions and 208 deletions
|
|
@ -1,7 +1,10 @@
|
|||
import { sortBy } from "lodash";
|
||||
import { GetSwapInfoResponseExt } from "models/tauriModelExt";
|
||||
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
|
||||
import type { AppDispatch, RootState } from "renderer/store/storeRenderer";
|
||||
import { parseDateString } from "utils/parseUtils";
|
||||
import { useMemo } from "react";
|
||||
import { isCliLogRelatedToSwap } from "models/cliModel";
|
||||
|
||||
export const useAppDispatch = () => useDispatch<AppDispatch>();
|
||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
||||
|
|
@ -26,7 +29,9 @@ export function useIsContextAvailable() {
|
|||
return useAppSelector((state) => state.rpc.status?.type === "Available");
|
||||
}
|
||||
|
||||
export function useSwapInfo(swapId: string | null) {
|
||||
export function useSwapInfo(
|
||||
swapId: string | null,
|
||||
): GetSwapInfoResponseExt | null {
|
||||
return useAppSelector((state) =>
|
||||
swapId ? state.rpc.state.swapInfos[swapId] ?? null : null,
|
||||
);
|
||||
|
|
@ -36,11 +41,21 @@ export function useActiveSwapId() {
|
|||
return useAppSelector((s) => s.swap.state?.swapId ?? null);
|
||||
}
|
||||
|
||||
export function useActiveSwapInfo() {
|
||||
export function useActiveSwapInfo(): GetSwapInfoResponseExt | null {
|
||||
const swapId = useActiveSwapId();
|
||||
return useSwapInfo(swapId);
|
||||
}
|
||||
|
||||
export function useActiveSwapLogs() {
|
||||
const swapId = useActiveSwapId();
|
||||
const logs = useAppSelector((s) => s.rpc.logs);
|
||||
|
||||
return useMemo(
|
||||
() => logs.filter((log) => isCliLogRelatedToSwap(log, swapId)),
|
||||
[logs, swapId],
|
||||
);
|
||||
}
|
||||
|
||||
export function useAllProviders() {
|
||||
return useAppSelector((state) => {
|
||||
const registryProviders = state.providers.registry.providers || [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue