diff --git a/src/components/AccountNotifications.tsx b/src/components/AccountNotifications.tsx index b11d05e5b..411cdb369 100644 --- a/src/components/AccountNotifications.tsx +++ b/src/components/AccountNotifications.tsx @@ -31,30 +31,31 @@ export const AccountNotifications = (props: IProps) => { ), ); - const [showNotifications, setShowNotifications] = useState(true); + const [showAccountNotifications, setShowAccountNotifications] = + useState(true); - const toggleNotifications = () => { - setShowNotifications(!showNotifications); + const toggleAccountNotifications = () => { + setShowAccountNotifications(!showAccountNotifications); }; const ChevronIcon = notifications.length === 0 ? ChevronLeftIcon - : showNotifications + : showAccountNotifications ? ChevronDownIcon : ChevronUpIcon; - const toggleNotificationsLabel = + const toggleAccountNotificationsLabel = notifications.length === 0 ? 'No notifications for account' - : showNotifications + : showAccountNotifications ? 'Hide account notifications' : 'Show account notifications'; return ( <> {showAccountHostname && ( -
+
-
+
@@ -77,7 +79,7 @@ export const AccountNotifications = (props: IProps) => {
)} - {showNotifications && + {showAccountNotifications && Object.values(groupedNotifications).map((repoNotifications) => { const repoSlug = repoNotifications[0].repository.full_name; diff --git a/src/components/Repository.tsx b/src/components/Repository.tsx index ace1d48a4..835eb7069 100644 --- a/src/components/Repository.tsx +++ b/src/components/Repository.tsx @@ -1,5 +1,11 @@ -import { CheckIcon, MarkGithubIcon, ReadIcon } from '@primer/octicons-react'; -import { type FC, useCallback, useContext } from 'react'; +import { + CheckIcon, + ChevronDownIcon, + ChevronUpIcon, + MarkGithubIcon, + ReadIcon, +} from '@primer/octicons-react'; +import { type FC, useCallback, useContext, useState } from 'react'; import { AppContext } from '../context/App'; import type { Notification } from '../typesGitHub'; import { openRepository } from '../utils/links'; @@ -28,10 +34,25 @@ export const RepositoryNotifications: FC = ({ const avatarUrl = repoNotifications[0].repository.owner.avatar_url; const repoSlug = repoNotifications[0].repository.full_name; + const [showRepositoryNotifications, setShowRepositoryNotifications] = + useState(true); + + const toggleRepositoryNotifications = () => { + setShowRepositoryNotifications(!showRepositoryNotifications); + }; + + const ChevronIcon = showRepositoryNotifications + ? ChevronDownIcon + : ChevronUpIcon; + + const toggleRepositoryNotificationsLabel = showRepositoryNotifications + ? 'Hide repository notifications' + : 'Show repository notifications'; + return ( <> -
-
+
+
{avatarUrl ? ( = ({
+
- {repoNotifications.map((obj) => ( - - ))} + {showRepositoryNotifications && + repoNotifications.map((obj) => ( + + ))} ); }; diff --git a/src/components/__snapshots__/AccountNotifications.test.tsx.snap b/src/components/__snapshots__/AccountNotifications.test.tsx.snap index fbd8f9167..f002b5238 100644 --- a/src/components/__snapshots__/AccountNotifications.test.tsx.snap +++ b/src/components/__snapshots__/AccountNotifications.test.tsx.snap @@ -6,7 +6,7 @@ exports[`components/AccountNotifications.tsx should render itself (github.com wi "baseElement":
-
+
-
+