feat(gui): Partially available global state (#593)

* feat(gui): Partially availiable global state

* move tauri command into own module

* move commands list into src-tauri/src/commands.rs

* cleanup swap/src/cli/api.rs

* add contextRequirement attribute to PromiseInvokeButton

* amend

* allow wallet operation on partially availiable context

* improvements

* fix some linter errors

* limit amount of logs to 5k

* keep behaviour from before

* make sure if swapId is null useActiveSwapLogs, return no logs

* remove unused variable

* create ContextStatusType enum
This commit is contained in:
Mohan 2025-10-02 21:28:12 +02:00 committed by GitHub
parent 3b701fe1c5
commit 7d019bfb30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 2361 additions and 2080 deletions

View file

@ -16,6 +16,7 @@ import {
isPendingSendMoneroApprovalEvent,
PendingPasswordApprovalRequest,
isPendingPasswordApprovalEvent,
isContextFullyInitialized,
} from "models/tauriModelExt";
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
import type { AppDispatch, RootState } from "renderer/store/storeRenderer";
@ -28,7 +29,6 @@ import { RatesState } from "./features/ratesSlice";
import {
TauriBackgroundProgress,
TauriBitcoinSyncProgress,
TauriContextStatusEvent,
} from "models/tauriModel";
export const useAppDispatch = () => useDispatch<AppDispatch>();
@ -111,9 +111,7 @@ export function useIsSpecificSwapRunning(swapId: string | null) {
}
export function useIsContextAvailable() {
return useAppSelector(
(state) => state.rpc.status === TauriContextStatusEvent.Available,
);
return useAppSelector((state) => isContextFullyInitialized(state.rpc.status));
}
/// We do not use a sanity check here, as opposed to the other useSwapInfo hooks,
@ -139,10 +137,13 @@ export function useActiveSwapLogs() {
const swapId = useActiveSwapId();
const logs = useAppSelector((s) => s.logs.state.logs);
return useMemo(
() => logs.filter((log) => isCliLogRelatedToSwap(log, swapId)),
[logs, swapId],
);
return useMemo(() => {
if (swapId == null) {
return [];
}
return logs.filter((log) => isCliLogRelatedToSwap(log.log, swapId));
}, [logs, swapId]);
}
export function useAllMakers() {