diff --git a/apps/wallet/src/ui/app/shared/toaster/index.tsx b/apps/wallet/src/ui/app/shared/toaster/index.tsx index f0c3d255e5..2c5815a959 100644 --- a/apps/wallet/src/ui/app/shared/toaster/index.tsx +++ b/apps/wallet/src/ui/app/shared/toaster/index.tsx @@ -2,57 +2,40 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { useMenuIsOpen } from '_components'; -import { useAppSelector } from '_hooks'; -import { getNavIsVisible } from '_redux/slices/app'; -import cl from 'clsx'; +import { useEffect } from 'react'; import { useLocation } from 'react-router-dom'; +import { useMenuIsOpen } from '_components'; import { Portal } from '../Portal'; -import { useEffect } from 'react'; import { Toaster as ToasterCore, toast, useToasterStore } from '@iota/core'; -export type ToasterProps = { - bottomNavEnabled?: boolean; -}; +const ROUTES_WITH_BOTTOM_CONTENT = [ + '/send', + '/dapp/connect', + '/dapp/approve', + '/accounts/import-ledger-accounts', + '/accounts/manage/accounts-finder', + '/accounts/manage', +]; const LIMIT_MAX_TOASTS = 5; -function getBottomSpace(pathname: string, isMenuVisible: boolean, isBottomNavSpace: boolean) { +function getBottomSpace(pathname: string, isMenuVisible: boolean, hasBottomNavSpace: boolean) { if (isMenuVisible) { - return '!bottom-28'; + return ' !bottom-28'; } - const overlayWithActionButton = [ - '/auto-lock', - '/manage/accounts-finder', - '/accounts/import-ledger-accounts', - '/send', - '/accounts/forgot-password/recover-many', - '/accounts/manage', - ].includes(pathname); - - const matchDynamicPaths = ['/dapp/connect', '/dapp/approve'].some((path) => - pathname.startsWith(path), - ); + const hasBottomContent = ROUTES_WITH_BOTTOM_CONTENT.some((path) => pathname.startsWith(path)); - if (overlayWithActionButton || isBottomNavSpace || matchDynamicPaths) { - return '!bottom-20'; + if (hasBottomNavSpace || hasBottomContent) { + return ' !bottom-20'; } return ''; } -export function Toaster({ bottomNavEnabled = false }: ToasterProps) { +export function Toaster({ bottomNavEnabled = false }: { bottomNavEnabled?: boolean }) { const { pathname } = useLocation(); - const menuVisible = useMenuIsOpen(); - const isBottomNavVisible = useAppSelector(getNavIsVisible); - const bottomSpace = getBottomSpace( - pathname, - menuVisible, - isBottomNavVisible && bottomNavEnabled, - ); - const { toasts } = useToasterStore(); useEffect(() => { @@ -62,10 +45,12 @@ export function Toaster({ bottomNavEnabled = false }: ToasterProps) { .forEach((t) => toast.dismiss(t.id)); }, [toasts]); + const bottomSpace = getBottomSpace(pathname, menuVisible, bottomNavEnabled); + return (