1- const { shell } = require ( 'electron' ) ;
2-
31import React , { useCallback , useContext } from 'react' ;
42import { formatDistanceToNow , parseISO } from 'date-fns' ;
53import { CheckIcon , MuteIcon } from '@primer/octicons-react' ;
64
75import { formatReason , getNotificationTypeIcon } from '../utils/github-api' ;
8- import { generateGitHubWebUrl } from '../utils/helpers' ;
6+ import { openInBrowser } from '../utils/helpers' ;
97import { Notification } from '../typesGithub' ;
108import { AppContext } from '../context/App' ;
119
@@ -18,8 +16,8 @@ export const NotificationRow: React.FC<IProps> = ({
1816 notification,
1917 hostname,
2018} ) => {
21- const { settings, accounts } = useContext ( AppContext ) ;
22- const { markNotification , unsubscribeNotification } = useContext ( AppContext ) ;
19+ const { settings, accounts, markNotification , unsubscribeNotification } =
20+ useContext ( AppContext ) ;
2321
2422 const pressTitle = useCallback ( ( ) => {
2523 openBrowser ( ) ;
@@ -29,17 +27,10 @@ export const NotificationRow: React.FC<IProps> = ({
2927 }
3028 } , [ settings ] ) ;
3129
32- const openBrowser = useCallback ( ( ) => {
33- // Some Notification types from GitHub are missing urls in their subjects.
34- if ( notification . subject . url ) {
35- const url = generateGitHubWebUrl (
36- notification . subject . url ,
37- notification . id ,
38- accounts . user ?. id
39- ) ;
40- shell . openExternal ( url ) ;
41- }
42- } , [ notification ] ) ;
30+ const openBrowser = useCallback (
31+ ( ) => openInBrowser ( notification , accounts ) ,
32+ [ notification ]
33+ ) ;
4334
4435 const unsubscribe = ( event : React . MouseEvent < HTMLElement > ) => {
4536 // Don't trigger onClick of parent element.
0 commit comments