Skip to content

Commit

Permalink
fix: add comment + rename selector
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Nov 21, 2023
1 parent 98c9ede commit a32b713
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/dashboard/RecoveryInProgress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import RecoveryPending from '@/public/images/common/recovery-pending.svg'
import ExternalLink from '@/components/common/ExternalLink'
import { useHasFeature } from '@/hooks/useChains'
import { FEATURES } from '@/utils/chains'
import { selectAllRecoveryQueues } from '@/store/recoverySlice'
import { selectRecoveryQueues } from '@/store/recoverySlice'
import madProps from '@/utils/mad-props'
import { Countdown } from '@/components/common/Countdown'
import { useRecoveryTxState } from '@/hooks/useRecoveryTxState'
Expand Down Expand Up @@ -82,7 +82,7 @@ function _RecoveryInProgressWidget({ nextTx }: { nextTx: RecoveryQueueItem }): R
// Appease React TypeScript warnings
const _useTimestamp = () => useClock(60_000) // Countdown does not display
const _useSupportsRecovery = () => useHasFeature(FEATURES.RECOVERY)
const _useQueuedRecoveryTxs = () => useAppSelector(selectAllRecoveryQueues)
const _useQueuedRecoveryTxs = () => useAppSelector(selectRecoveryQueues)

export const RecoveryInProgress = madProps(_RecoveryInProgress, {
timestamp: _useTimestamp,
Expand Down
4 changes: 2 additions & 2 deletions src/components/recovery/RecoveryList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import type { ReactElement } from 'react'

import { TxListGrid } from '@/components/transactions/TxList'
import { RecoveryListItem } from '@/components/recovery/RecoveryListItem'
import { selectAllRecoveryQueues } from '@/store/recoverySlice'
import { selectRecoveryQueues } from '@/store/recoverySlice'
import { useAppSelector } from '@/store'

import labelCss from '@/components/transactions/GroupLabel/styles.module.css'

export function RecoveryList(): ReactElement | null {
const queue = useAppSelector(selectAllRecoveryQueues)
const queue = useAppSelector(selectRecoveryQueues)

if (queue.length === 0) {
return null
Expand Down
6 changes: 3 additions & 3 deletions src/store/__tests__/recoverySlice.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigNumber } from 'ethers'
import { faker } from '@faker-js/faker'

import { selectDelayModifierByGuardian, selectAllRecoveryQueues, selectDelayModifierByTxHash } from '../recoverySlice'
import { selectDelayModifierByGuardian, selectRecoveryQueues, selectDelayModifierByTxHash } from '../recoverySlice'
import type { RecoveryState } from '../recoverySlice'
import type { RootState } from '..'

Expand Down Expand Up @@ -34,7 +34,7 @@ describe('recoverySlice', () => {
})
})

describe('selectAllRecoveryQueues', () => {
describe('selectRecoveryQueues', () => {
it('should return all recovery queues sorted by timestamp', () => {
const delayModifier1 = {
queue: [{ timestamp: BigNumber.from(1) }, { timestamp: BigNumber.from(3) }],
Expand All @@ -51,7 +51,7 @@ describe('recoverySlice', () => {
const data = [delayModifier1, delayModifier2, delayModifier3]

expect(
selectAllRecoveryQueues({
selectRecoveryQueues({
recovery: { data },
} as unknown as RootState),
).toStrictEqual([
Expand Down
3 changes: 2 additions & 1 deletion src/store/recoverySlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type RecoveryQueueItem = TransactionAddedEvent & {
executor: string
}

// State of current Safe, populated on load
export type RecoveryState = Array<{
address: string
guardians: Array<string>
Expand All @@ -39,7 +40,7 @@ export const selectDelayModifierByGuardian = createSelector(
},
)

export const selectAllRecoveryQueues = createSelector(selectRecovery, (recovery) => {
export const selectRecoveryQueues = createSelector(selectRecovery, (recovery) => {
return recovery.flatMap(({ queue }) => queue).sort((a, b) => a.timestamp.sub(b.timestamp).toNumber())
})

Expand Down

0 comments on commit a32b713

Please sign in to comment.