Skip to content

Commit

Permalink
Refactor: fetch pending queue only in 1/N Safes
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Aug 7, 2023
1 parent beae29d commit 3824772
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/hooks/usePendingTxs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ export const useHasPendingTxs = (): boolean => {
return pendingIds.length > 0
}

/**
* Show unsigned pending queue only in 1/X Safes
*/
export const useShowUnsignedQueue = (): boolean => {
const { safe } = useSafeInfo()
const hasPending = useHasPendingTxs()
return safe.threshold === 1 && hasPending
}

export const usePendingTxsQueue = (): {
page?: TransactionListPage
error?: string
Expand Down
6 changes: 3 additions & 3 deletions src/pages/transactions/queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import TxHeader from '@/components/transactions/TxHeader'
import BatchExecuteButton from '@/components/transactions/BatchExecuteButton'
import { Box } from '@mui/material'
import { BatchExecuteHoverProvider } from '@/components/transactions/BatchExecuteButton/BatchExecuteHoverProvider'
import { useHasPendingTxs, usePendingTxsQueue } from '@/hooks/usePendingTxs'
import { usePendingTxsQueue, useShowUnsignedQueue } from '@/hooks/usePendingTxs'

const Queue: NextPage = () => {
const hasPending = useHasPendingTxs()
const showPending = useShowUnsignedQueue()

return (
<>
Expand All @@ -25,7 +25,7 @@ const Queue: NextPage = () => {
<main>
<Box mb={4}>
{/* Pending unsigned transactions */}
{hasPending && <PaginatedTxns useTxns={usePendingTxsQueue} />}
{showPending && <PaginatedTxns useTxns={usePendingTxsQueue} />}

{/* The main queue of signed transactions */}
<PaginatedTxns useTxns={useTxQueue} />
Expand Down

0 comments on commit 3824772

Please sign in to comment.