diff --git a/src-gui/src/renderer/background.ts b/src-gui/src/renderer/background.ts index f610ac45..ecbdc658 100644 --- a/src-gui/src/renderer/background.ts +++ b/src-gui/src/renderer/background.ts @@ -2,12 +2,12 @@ import { listen } from "@tauri-apps/api/event"; import { TauriContextStatusEvent, TauriEvent } from "models/tauriModel"; import { contextStatusEventReceived, - receivedCliLog, rpcSetBalance, timelockChangeEventReceived, approvalEventReceived, backgroundProgressEventReceived, } from "store/features/rpcSlice"; +import { receivedCliLog } from "store/features/logsSlice"; import { poolStatusReceived } from "store/features/poolSlice"; import { swapProgressEventReceived } from "store/features/swapSlice"; import logger from "utils/logger"; @@ -24,8 +24,6 @@ import { listSellersAtRendezvousPoint, refreshApprovals, updateAllNodeStatuses, - fetchAndUpdateBackgroundItems, - fetchAndUpdateApprovalItems, } from "./rpc"; import { store } from "./store/storeRenderer"; import { exhaustiveGuard } from "utils/typescriptUtils"; diff --git a/src-gui/src/renderer/components/modal/feedback/useFeedback.ts b/src-gui/src/renderer/components/modal/feedback/useFeedback.ts index 5432fe26..e68287b8 100644 --- a/src-gui/src/renderer/components/modal/feedback/useFeedback.ts +++ b/src-gui/src/renderer/components/modal/feedback/useFeedback.ts @@ -82,7 +82,7 @@ export function useFeedback() { try { if (inputState.isDaemonLogsRedacted) { - redactLogs(store.getState().rpc?.logs) + redactLogs(store.getState().logs?.state.logs) .then((redactedLogs) => { setLogsState((prev) => ({ ...prev, @@ -98,7 +98,7 @@ export function useFeedback() { } else { setLogsState((prev) => ({ ...prev, - daemonLogs: store.getState().rpc?.logs, + daemonLogs: store.getState().logs?.state.logs, })); setError(null); } diff --git a/src-gui/src/renderer/components/pages/help/DaemonControlBox.tsx b/src-gui/src/renderer/components/pages/help/DaemonControlBox.tsx index bec674dc..654fcc57 100644 --- a/src-gui/src/renderer/components/pages/help/DaemonControlBox.tsx +++ b/src-gui/src/renderer/components/pages/help/DaemonControlBox.tsx @@ -12,7 +12,7 @@ import { revealItemInDir } from "@tauri-apps/plugin-opener"; import { TauriContextStatusEvent } from "models/tauriModel"; export default function DaemonControlBox() { - const logs = useAppSelector((s) => s.rpc.logs); + const logs = useAppSelector((s) => s.logs.state.logs); // The daemon can be manually started if it has failed or if it has not been started yet const canContextBeManuallyStarted = useAppSelector( diff --git a/src-gui/src/renderer/components/pages/history/table/ExportLogsButton.tsx b/src-gui/src/renderer/components/pages/history/table/ExportLogsButton.tsx index c947605f..5a37f30b 100644 --- a/src-gui/src/renderer/components/pages/history/table/ExportLogsButton.tsx +++ b/src-gui/src/renderer/components/pages/history/table/ExportLogsButton.tsx @@ -14,7 +14,7 @@ export default function ExportLogsButton({ }: ExportLogsButtonProps) { async function handleExportLogs() { const swapLogs = await getLogsOfSwap(swap_id, false); - const daemonLogs = store.getState().rpc?.logs; + const daemonLogs = store.getState().logs?.state.logs; const logContent = { swap_logs: logsToRawString(swapLogs.logs), diff --git a/src-gui/src/renderer/store/storeRenderer.ts b/src-gui/src/renderer/store/storeRenderer.ts index faa4f7df..c19fec51 100644 --- a/src-gui/src/renderer/store/storeRenderer.ts +++ b/src-gui/src/renderer/store/storeRenderer.ts @@ -17,7 +17,7 @@ import { LazyStore } from "@tauri-apps/plugin-store"; const rootPersistConfig = { key: "gui-global-state-store", storage: sessionStorage, - blacklist: ["settings", "conversations"], + blacklist: ["settings", "conversations", "logs"], }; // Use Tauri's store plugin for persistent settings diff --git a/src-gui/src/store/combinedReducer.ts b/src-gui/src/store/combinedReducer.ts index 8908ede7..ca868b19 100644 --- a/src-gui/src/store/combinedReducer.ts +++ b/src-gui/src/store/combinedReducer.ts @@ -8,6 +8,7 @@ import nodesSlice from "./features/nodesSlice"; import conversationsSlice from "./features/conversationsSlice"; import poolSlice from "./features/poolSlice"; import walletSlice from "./features/walletSlice"; +import logsSlice from "./features/logsSlice"; export const reducers = { swap: swapReducer, @@ -20,4 +21,5 @@ export const reducers = { conversations: conversationsSlice, pool: poolSlice, wallet: walletSlice, + logs: logsSlice, }; diff --git a/src-gui/src/store/features/logsSlice.ts b/src-gui/src/store/features/logsSlice.ts new file mode 100644 index 00000000..16575bd8 --- /dev/null +++ b/src-gui/src/store/features/logsSlice.ts @@ -0,0 +1,37 @@ +import { createSlice, PayloadAction } from "@reduxjs/toolkit"; +import { TauriLogEvent } from "models/tauriModel"; +import { parseLogsFromString } from "utils/parseUtils"; +import { CliLog } from "models/cliModel"; + +interface LogsState { + logs: (CliLog | string)[]; +} + +export interface LogsSlice { + state: LogsState; +} + +const initialState: LogsSlice = { + state: { + logs: [], + }, +}; + +export const logsSlice = createSlice({ + name: "logs", + initialState, + reducers: { + receivedCliLog(slice, action: PayloadAction) { + const buffer = action.payload.buffer; + const logs = parseLogsFromString(buffer); + const logsWithoutExisting = logs.filter( + (log) => !slice.state.logs.includes(log), + ); + slice.state.logs = slice.state.logs.concat(logsWithoutExisting); + }, + }, +}); + +export const { receivedCliLog } = logsSlice.actions; + +export default logsSlice.reducer; diff --git a/src-gui/src/store/features/rpcSlice.ts b/src-gui/src/store/features/rpcSlice.ts index 856cde97..0ae618ee 100644 --- a/src-gui/src/store/features/rpcSlice.ts +++ b/src-gui/src/store/features/rpcSlice.ts @@ -1,7 +1,6 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { ExtendedMakerStatus, MakerStatus } from "models/apiModel"; import { - TauriLogEvent, GetSwapInfoResponse, TauriContextStatusEvent, TauriTimelockChangeEvent, @@ -12,8 +11,6 @@ import { } from "models/tauriModel"; import { MoneroRecoveryResponse } from "../../models/rpcModel"; import { GetSwapInfoResponseExt } from "models/tauriModelExt"; -import { parseLogsFromString } from "utils/parseUtils"; -import { CliLog } from "models/cliModel"; import logger from "utils/logger"; interface State { @@ -43,7 +40,6 @@ interface State { export interface RPCSlice { status: TauriContextStatusEvent | null; state: State; - logs: (CliLog | string)[]; } const initialState: RPCSlice = { @@ -58,21 +54,12 @@ const initialState: RPCSlice = { backgroundRefund: null, approvalRequests: {}, }, - logs: [], }; export const rpcSlice = createSlice({ name: "rpc", initialState, reducers: { - receivedCliLog(slice, action: PayloadAction) { - const buffer = action.payload.buffer; - const logs = parseLogsFromString(buffer); - const logsWithoutExisting = logs.filter( - (log) => !slice.logs.includes(log), - ); - slice.logs = slice.logs.concat(logsWithoutExisting); - }, contextStatusEventReceived( slice, action: PayloadAction, @@ -173,7 +160,6 @@ export const rpcSlice = createSlice({ export const { contextStatusEventReceived, - receivedCliLog, rpcSetBalance, rpcSetWithdrawTxId, rpcResetWithdrawTxId, diff --git a/src-gui/src/store/hooks.ts b/src-gui/src/store/hooks.ts index c987a629..7edcf6db 100644 --- a/src-gui/src/store/hooks.ts +++ b/src-gui/src/store/hooks.ts @@ -137,7 +137,7 @@ export function useActiveSwapInfo(): GetSwapInfoResponseExt | null { export function useActiveSwapLogs() { const swapId = useActiveSwapId(); - const logs = useAppSelector((s) => s.rpc.logs); + const logs = useAppSelector((s) => s.logs.state.logs); return useMemo( () => logs.filter((log) => isCliLogRelatedToSwap(log, swapId)),