From 16e1faad3096e287cfeadae30da361a7a22a40dc Mon Sep 17 00:00:00 2001 From: turnerran Date: Fri, 1 Sep 2023 21:40:18 +0200 Subject: [PATCH] Removed some redundant code --- .../src/components/BoosterChat/BoosterChat.tsx | 16 ++++------------ website/src/components/CustomSidebarItem.jsx | 12 ++++++------ website/src/theme/DocSidebarItem/index.js | 13 ++++++------- .../src/theme/NavbarItem/CustomNavbarItem.tsx | 9 ++------- website/src/theme/NavbarItem/NavbarNavLink.js | 12 ++++++------ 5 files changed, 24 insertions(+), 38 deletions(-) diff --git a/website/src/components/BoosterChat/BoosterChat.tsx b/website/src/components/BoosterChat/BoosterChat.tsx index d1033d7c6..012b90973 100644 --- a/website/src/components/BoosterChat/BoosterChat.tsx +++ b/website/src/components/BoosterChat/BoosterChat.tsx @@ -24,7 +24,7 @@ export default function BoosterChat(): JSX.Element { } const handleSearch = async (query: string) => { - if (query?.trim() === '' || query === null) { + if (query?.trim() === '') { return } @@ -79,11 +79,8 @@ export default function BoosterChat(): JSX.Element { {!hasSearched && (
-
)} - + ) } diff --git a/website/src/components/CustomSidebarItem.jsx b/website/src/components/CustomSidebarItem.jsx index 373616192..307d28ba4 100644 --- a/website/src/components/CustomSidebarItem.jsx +++ b/website/src/components/CustomSidebarItem.jsx @@ -1,17 +1,17 @@ -import React from 'react'; +import React from 'react' function CustomSidebarItem({ item }) { const handleClick = () => { - if (customProps && customProps.trackingEvent) { - fathom.trackGoal(customProps.trackingEvent, 0); + if (customProps?.trackingEvent) { + fathom.trackGoal(customProps.trackingEvent, 0) } - }; + } return ( {item.label} - ); + ) } -export default CustomSidebarItem; \ No newline at end of file +export default CustomSidebarItem diff --git a/website/src/theme/DocSidebarItem/index.js b/website/src/theme/DocSidebarItem/index.js index 215f1bff2..3fb8c586b 100644 --- a/website/src/theme/DocSidebarItem/index.js +++ b/website/src/theme/DocSidebarItem/index.js @@ -1,17 +1,16 @@ -import React from 'react'; -import DocSidebarItem from '@theme-original/DocSidebarItem'; +import React from 'react' +import DocSidebarItem from '@theme-original/DocSidebarItem' export default function DocSidebarItemWrapper(props) { const handleClick = (customProps) => { - if (customProps && customProps.trackingEvent) { - fathom.trackGoal(customProps.trackingEvent, 0); + if (customProps?.trackingEvent) { + fathom.trackGoal(customProps.trackingEvent, 0) } - }; + } return (
handleClick(props.item.customProps)}>
- ); + ) } - diff --git a/website/src/theme/NavbarItem/CustomNavbarItem.tsx b/website/src/theme/NavbarItem/CustomNavbarItem.tsx index b67568388..bc2a99f7a 100644 --- a/website/src/theme/NavbarItem/CustomNavbarItem.tsx +++ b/website/src/theme/NavbarItem/CustomNavbarItem.tsx @@ -22,7 +22,7 @@ export default function CustomNavbarItem(props: { imageURL: string; altText: str } const handleSearch = async (query: string, controller: AbortController) => { - if (query?.trim() === '' || query === null) { + if (query?.trim() === '') { return } @@ -125,12 +125,7 @@ export default function CustomNavbarItem(props: { imageURL: string; altText: str resetSearchResponse={null} /> - + ) diff --git a/website/src/theme/NavbarItem/NavbarNavLink.js b/website/src/theme/NavbarItem/NavbarNavLink.js index eff4882f3..c35d90d0b 100644 --- a/website/src/theme/NavbarItem/NavbarNavLink.js +++ b/website/src/theme/NavbarItem/NavbarNavLink.js @@ -1,16 +1,16 @@ -import React from 'react'; -import NavbarNavLink from '@theme-original/NavbarItem/NavbarNavLink'; +import React from 'react' +import NavbarNavLink from '@theme-original/NavbarItem/NavbarNavLink' export default function NavbarNavLinkWrapper(props) { const handleClick = (customProps) => { - if (customProps && customProps.trackingEvent) { - fathom.trackGoal(customProps.trackingEvent, 0); + if (customProps?.trackingEvent) { + fathom.trackGoal(customProps.trackingEvent, 0) } - }; + } return (
handleClick(props.customProps)}>
- ); + ) }