@@ -69,59 +69,57 @@ interface IProps {
6969 markNotification : ( id : string , hostname : string ) => void ;
7070}
7171
72- export class NotificationItem extends React . Component < IProps , { } > {
73- pressTitle ( ) {
74- this . openBrowser ( ) ;
72+ export const NotificationItem : React . FC < IProps > = props = > {
73+ const pressTitle = ( ) => {
74+ openBrowser ( ) ;
7575
76- if ( this . props . markOnClick ) {
77- this . markAsRead ( ) ;
76+ if ( props . markOnClick ) {
77+ markAsRead ( ) ;
7878 }
79- }
79+ } ;
8080
81- openBrowser ( ) {
82- const url = generateGitHubWebUrl ( this . props . notification . subject . url ) ;
81+ const openBrowser = ( ) => {
82+ const url = generateGitHubWebUrl ( props . notification . subject . url ) ;
8383 shell . openExternal ( url ) ;
84- }
84+ } ;
8585
86- markAsRead ( ) {
87- const { hostname, notification } = this . props ;
88- this . props . markNotification ( notification . id , hostname ) ;
89- }
86+ const markAsRead = ( ) => {
87+ const { hostname, notification } = props ;
88+ props . markNotification ( notification . id , hostname ) ;
89+ } ;
9090
91- render ( ) {
92- const { notification } = this . props ;
93- const reason = formatReason ( notification . reason ) ;
94- const typeIcon = getNotificationTypeIcon ( notification . subject . type ) ;
95- const updatedAt = formatDistanceToNow ( parseISO ( notification . updated_at ) , {
96- addSuffix : true ,
97- } ) ;
98-
99- return (
100- < Wrapper >
101- < IconWrapper >
102- < Octicon
103- icon = { getIconByName ( typeIcon ) }
104- size = { 20 }
105- ariaLabel = { notification . subject . type }
106- />
107- </ IconWrapper >
108- < Main onClick = { ( ) => this . pressTitle ( ) } role = "main" >
109- < Title > { notification . subject . title } </ Title >
110-
111- < Details >
112- < span title = { reason . description } > { reason . type } </ span > - Updated{ ' ' }
113- { updatedAt }
114- </ Details >
115- </ Main >
116- < IconWrapper >
117- < Button onClick = { ( ) => this . markAsRead ( ) } >
118- < Octicon icon = { Check } size = { 20 } ariaLabel = "Mark as Read" />
119- </ Button >
120- </ IconWrapper >
121- </ Wrapper >
122- ) ;
123- }
124- }
91+ const { notification } = props ;
92+ const reason = formatReason ( notification . reason ) ;
93+ const typeIcon = getNotificationTypeIcon ( notification . subject . type ) ;
94+ const updatedAt = formatDistanceToNow ( parseISO ( notification . updated_at ) , {
95+ addSuffix : true ,
96+ } ) ;
97+
98+ return (
99+ < Wrapper >
100+ < IconWrapper >
101+ < Octicon
102+ icon = { getIconByName ( typeIcon ) }
103+ size = { 20 }
104+ ariaLabel = { notification . subject . type }
105+ />
106+ </ IconWrapper >
107+ < Main onClick = { ( ) => pressTitle ( ) } role = "main" >
108+ < Title > { notification . subject . title } </ Title >
109+
110+ < Details >
111+ < span title = { reason . description } > { reason . type } </ span > - Updated{ ' ' }
112+ { updatedAt }
113+ </ Details >
114+ </ Main >
115+ < IconWrapper >
116+ < Button onClick = { ( ) => markAsRead ( ) } >
117+ < Octicon icon = { Check } size = { 20 } ariaLabel = "Mark as Read" />
118+ </ Button >
119+ </ IconWrapper >
120+ </ Wrapper >
121+ ) ;
122+ } ;
125123
126124export function mapStateToProps ( state : AppState ) {
127125 return {
0 commit comments