From 26ba204fed5a3a9c6cecd92ee6fba8479ea855b5 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Mon, 27 May 2024 17:05:22 +0200 Subject: [PATCH] Rm set batch --- src/hooks/useDraftBatch.ts | 19 ++----------------- src/store/batchSlice.ts | 19 +++---------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/hooks/useDraftBatch.ts b/src/hooks/useDraftBatch.ts index 5dcf1f536e..a4794a24e6 100644 --- a/src/hooks/useDraftBatch.ts +++ b/src/hooks/useDraftBatch.ts @@ -3,7 +3,7 @@ import { useAppDispatch, useAppSelector } from '@/store' import useChainId from './useChainId' import useSafeAddress from './useSafeAddress' import type { DraftBatchItem } from '@/store/batchSlice' -import { selectBatchBySafe, addTx, removeTx, setBatch } from '@/store/batchSlice' +import { selectBatchBySafe, addTx, removeTx } from '@/store/batchSlice' import { type TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' import { BATCH_EVENTS, trackEvent } from '@/services/analytics' import { txDispatch, TxEvent } from '@/services/tx/txEvents' @@ -43,22 +43,7 @@ export const useUpdateBatch = () => { [dispatch, chainId, safeAddress], ) - const onSet = useCallback( - (items: DraftBatchItem[]) => { - dispatch( - setBatch({ - chainId, - safeAddress, - items, - }), - ) - - trackEvent({ ...BATCH_EVENTS.BATCH_REORDER }) - }, - [dispatch, chainId, safeAddress], - ) - - return [onAdd, onDelete, onSet] as const + return [onAdd, onDelete] as const } export const useDraftBatch = (): DraftBatchItem[] => { diff --git a/src/store/batchSlice.ts b/src/store/batchSlice.ts index 6a796b4526..4591aaad26 100644 --- a/src/store/batchSlice.ts +++ b/src/store/batchSlice.ts @@ -20,21 +20,6 @@ export const batchSlice = createSlice({ name: 'batch', initialState, reducers: { - // Set a batch (used for reordering) - setBatch: ( - state, - action: PayloadAction<{ - chainId: string - safeAddress: string - items: DraftBatchItem[] - }>, - ) => { - const { chainId, safeAddress, items } = action.payload - state[chainId] = state[chainId] || {} - // @ts-expect-error - state[chainId][safeAddress] = items - }, - // Add a tx to the batch addTx: ( state, @@ -47,9 +32,11 @@ export const batchSlice = createSlice({ const { chainId, safeAddress, txDetails } = action.payload state[chainId] = state[chainId] || {} state[chainId][safeAddress] = state[chainId][safeAddress] || [] + // @ts-expect-error state[chainId][safeAddress].push({ id: Math.random().toString(36).slice(2), timestamp: Date.now(), + // @ts-expect-error txDetails, }) }, @@ -71,7 +58,7 @@ export const batchSlice = createSlice({ }, }) -export const { setBatch, addTx, removeTx } = batchSlice.actions +export const { addTx, removeTx } = batchSlice.actions const selectAllBatches = (state: RootState): BatchTxsState => { return state[batchSlice.name] || initialState