Skip to content

Commit

Permalink
Fix: allow removing counterfactual safes from safe list (safe-global#…
Browse files Browse the repository at this point in the history
…4643)

* fix: allow removing counterfactual safes from safe list

* fix: handle multi chain CF safes
  • Loading branch information
jmealy authored Dec 13, 2024
1 parent 9f08316 commit d094768
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/sidebar/SafeListRemoveDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import type { ReactElement } from 'react'
import ModalDialog from '@/components/common/ModalDialog'
import { useAppDispatch } from '@/store'
import useAddressBook from '@/hooks/useAddressBook'
import { removeSafe } from '@/store/addedSafesSlice'
import Track from '@/components/common/Track'
import { OVERVIEW_EVENTS, OVERVIEW_LABELS } from '@/services/analytics'
import { AppRoutes } from '@/config/routes'
import router from 'next/router'
import { removeAddressBookEntry } from '@/store/addressBookSlice'
import { removeSafe, removeUndeployedSafe } from '@/store/slices'
import useSafeAddress from '@/hooks/useSafeAddress'
import useChainId from '@/hooks/useChainId'

const SafeListRemoveDialog = ({
handleClose,
Expand All @@ -24,13 +26,20 @@ const SafeListRemoveDialog = ({
chainId: string
}): ReactElement => {
const dispatch = useAppDispatch()
const safeAddress = useSafeAddress()
const safeChainId = useChainId()
const addressBook = useAddressBook()
const trackingLabel =
router.pathname === AppRoutes.welcome.accounts ? OVERVIEW_LABELS.login_page : OVERVIEW_LABELS.sidebar

const safe = addressBook?.[address] || address

const handleConfirm = () => {
const handleConfirm = async () => {
// When removing the current counterfactual safe, redirect to the accounts page
if (safeAddress === address && safeChainId === chainId) {
await router.push(AppRoutes.welcome.accounts)
}
dispatch(removeUndeployedSafe({ chainId, address }))
dispatch(removeSafe({ chainId, address }))
dispatch(removeAddressBookEntry({ chainId, address }))
handleClose()
Expand Down

0 comments on commit d094768

Please sign in to comment.