From 097917a1241dc41bbcfe9119e6c7cf7d083868d2 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Fri, 4 Aug 2023 15:54:05 +0200 Subject: [PATCH] fix: Open custom safe apps on click --- src/components/safe-apps/SafeAppCard/index.tsx | 13 ++++--------- src/components/safe-apps/SafeAppList/index.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/safe-apps/SafeAppCard/index.tsx b/src/components/safe-apps/SafeAppCard/index.tsx index 74ce3eed78..a583616b88 100644 --- a/src/components/safe-apps/SafeAppCard/index.tsx +++ b/src/components/safe-apps/SafeAppCard/index.tsx @@ -19,7 +19,6 @@ import SafeAppTags from '@/components/safe-apps/SafeAppTags' import { isOptimizedForBatchTransactions } from '@/components/safe-apps/utils' import { AppRoutes } from '@/config/routes' import BatchIcon from '@/public/images/apps/batch-icon.svg' -import { useOpenedSafeApps } from '@/hooks/safe-apps/useOpenedSafeApps' import css from './styles.module.css' export type SafeAppsViewMode = 'list-view' | 'grid-view' @@ -111,7 +110,7 @@ const SafeAppCardGridView = ({ openPreviewDrawer, }: SafeAppCardViewProps) => { return ( - + {/* Safe App Header */} { return ( - +
@@ -204,7 +203,6 @@ const SafeAppCardListView = ({ type SafeAppCardContainerProps = { onClickSafeApp?: () => void - safeApp?: SafeAppData safeAppUrl: string children: ReactNode height?: string @@ -213,18 +211,15 @@ type SafeAppCardContainerProps = { export const SafeAppCardContainer = ({ children, - safeApp, safeAppUrl, onClickSafeApp, height, className, }: SafeAppCardContainerProps) => { - const { openedSafeAppIds } = useOpenedSafeApps() - const handleClickSafeApp = (event: SyntheticEvent) => { - if (safeApp && !openedSafeAppIds.includes(safeApp.id)) { + if (onClickSafeApp) { event.preventDefault() - onClickSafeApp?.() + onClickSafeApp() } } diff --git a/src/components/safe-apps/SafeAppList/index.tsx b/src/components/safe-apps/SafeAppList/index.tsx index bd3fef8275..86d00ba73e 100644 --- a/src/components/safe-apps/SafeAppList/index.tsx +++ b/src/components/safe-apps/SafeAppList/index.tsx @@ -14,6 +14,7 @@ import useSafeAppPreviewDrawer from '@/hooks/safe-apps/useSafeAppPreviewDrawer' import css from './styles.module.css' import { Skeleton } from '@mui/material' import useLocalStorage from '@/services/local-storage/useLocalStorage' +import { useOpenedSafeApps } from '@/hooks/safe-apps/useOpenedSafeApps' type SafeAppListProps = { safeAppsList: SafeAppData[] @@ -38,6 +39,7 @@ const SafeAppList = ({ }: SafeAppListProps) => { const [safeAppsViewMode = GRID_VIEW_MODE, setSafeAppsViewMode] = useLocalStorage(VIEW_MODE_KEY) const { isPreviewDrawerOpen, previewDrawerApp, openPreviewDrawer, closePreviewDrawer } = useSafeAppPreviewDrawer() + const { openedSafeAppIds } = useOpenedSafeApps() const { filteredApps, query, setQuery, setSelectedCategories, setOptimizedWithBatchFilter, selectedCategories } = useSafeAppsFilters(safeAppsList) @@ -48,11 +50,11 @@ const SafeAppList = ({ (safeApp: SafeAppData) => { const isCustomApp = safeApp.id < 1 - if (isCustomApp) return + if (isCustomApp || openedSafeAppIds.includes(safeApp.id)) return return () => openPreviewDrawer(safeApp) }, - [openPreviewDrawer], + [openPreviewDrawer, openedSafeAppIds], ) return (