Skip to content

Commit

Permalink
Fix: reset tx list pages when Safe is changed (#2168)
Browse files Browse the repository at this point in the history
* Fix: reset tx list pages when Safe is changed

* Add the same fix for PaginatedMsgs
  • Loading branch information
katspaugh authored Jun 27, 2023
1 parent e20dcc3 commit b9e2b18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/common/PaginatedTxns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { type TxFilter, useTxFilter } from '@/utils/tx-history-filter'
import { isTransactionListItem } from '@/utils/transaction-guards'
import NoTransactionsIcon from '@/public/images/transactions/no-transactions.svg'
import { useHasPendingTxs } from '@/hooks/usePendingTxs'
import useSafeInfo from '@/hooks/useSafeInfo'

const NoQueuedTxns = () => {
return <PagePlaceholder img={<NoTransactionsIcon />} text="Queued transactions will appear here" />
Expand Down Expand Up @@ -68,11 +69,12 @@ const TxPage = ({
const PaginatedTxns = ({ useTxns }: { useTxns: typeof useTxHistory | typeof useTxQueue }): ReactElement => {
const [pages, setPages] = useState<string[]>([''])
const [filter] = useTxFilter()
const { safeAddress, safe } = useSafeInfo()

// Reset the pages when the filter changes
// Reset the pages when the Safe Account or filter changes
useEffect(() => {
setPages([''])
}, [filter, useTxns])
}, [filter, safe.chainId, safeAddress, useTxns])

// Trigger the next page load
const onNextPage = (pageUrl: string) => {
Expand Down
9 changes: 8 additions & 1 deletion src/components/safe-messages/PaginatedMsgs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from '@mui/material'
import { Typography, Link, SvgIcon } from '@mui/material'
import { useState } from 'react'
import { useEffect, useState } from 'react'
import type { ReactElement } from 'react'

import ErrorMessage from '@/components/tx/ErrorMessage'
Expand All @@ -12,6 +12,7 @@ import PagePlaceholder from '@/components/common/PagePlaceholder'
import MsgList from '@/components/safe-messages/MsgList'
import SkeletonTxList from '@/components/common/PaginatedTxns/SkeletonTxList'
import { HelpCenterArticle } from '@/config/constants'
import useSafeInfo from '@/hooks/useSafeInfo'

const NoMessages = (): ReactElement => {
return (
Expand Down Expand Up @@ -62,12 +63,18 @@ const MsgPage = ({

const PaginatedMsgs = (): ReactElement => {
const [pages, setPages] = useState<string[]>([''])
const { safeAddress, safe } = useSafeInfo()

// Trigger the next page load
const onNextPage = (pageUrl: string) => {
setPages((prev) => prev.concat(pageUrl))
}

// Reset the pages when the Safe Account changes
useEffect(() => {
setPages([''])
}, [safe.chainId, safeAddress])

return (
<Box mb={4} position="relative">
{pages.map((pageUrl, index) => (
Expand Down

0 comments on commit b9e2b18

Please sign in to comment.