From bfb7aeecad100ad2ef16f212ed4c23032a6cf9cf Mon Sep 17 00:00:00 2001 From: Arthur Dufour Date: Sun, 18 Feb 2024 09:35:48 +0100 Subject: [PATCH 1/4] feat: implement `unsubscribeRepository` --- src/components/Repository.tsx | 20 +++++++++++++++++--- src/context/App.tsx | 9 +++++++++ src/hooks/useNotifications.ts | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/components/Repository.tsx b/src/components/Repository.tsx index 3cdb5820a..f4cd1737f 100644 --- a/src/components/Repository.tsx +++ b/src/components/Repository.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useContext } from 'react'; -import { ReadIcon } from '@primer/octicons-react'; +import { BellSlashIcon, ReadIcon } from '@primer/octicons-react'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; import { AppContext } from '../context/App'; @@ -18,7 +18,8 @@ export const RepositoryNotifications: React.FC = ({ repoNotifications, hostname, }) => { - const { markRepoNotifications } = useContext(AppContext); + const { markRepoNotifications, unsubscribeRepository } = + useContext(AppContext); const openBrowser = useCallback(() => { const url = repoNotifications[0].repository.html_url; @@ -30,6 +31,11 @@ export const RepositoryNotifications: React.FC = ({ markRepoNotifications(repoSlug, hostname); }, [repoNotifications, hostname]); + const unsubscribe = useCallback(() => { + const repoSlug = repoNotifications[0].repository.full_name; + unsubscribeRepository(repoSlug, hostname); + }, [repoNotifications, hostname]); + const avatarUrl = repoNotifications[0].repository.owner.avatar_url; return ( @@ -40,7 +46,15 @@ export const RepositoryNotifications: React.FC = ({ {repoName} -
+
+ +
+