File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ const openNotification = async (id) => {
7878 await browser . windows . update ( tab . windowId , {
7979 focused : true
8080 } ) ;
81- await handler . markAsRead ( id , false ) ;
81+ if ( await handler . willAutoMarkAsRead ( id ) ) {
82+ await handler . markAsRead ( id , false ) ;
83+ }
8284 const newCount = await manager . getCount ( ) ;
8385 await updateBadge ( newCount ) ;
8486 }
Original file line number Diff line number Diff line change @@ -312,7 +312,27 @@ class GitHub {
312312
313313 async getNotificationDetails ( notification ) {
314314 if ( notification . subject . type === "RepositoryInvitation" || notification . subject . type === "RepositoryVulnerabilityAlert" || ! notification . subject . url ) {
315- return notification . repository ;
315+ const details = { ...notification . repository } ;
316+ switch ( notification . subject . type ) {
317+ case "RepositoryInvitation" :
318+ details . html_url = `${ notification . repository . html_url } /invitations` ;
319+ break ;
320+ case "RepositoryVulnerabilityAlert" :
321+ details . html_url = `${ notification . repository . html_url } /network/dependencies` ;
322+ break ;
323+ case "RepositoryDependabotAlertsThread" :
324+ details . html_url = `${ notification . repository . html_url } /security/dependabot` ;
325+ break ;
326+ case "CheckSuite" :
327+ details . html_url = `${ notification . repository . html_url } /actions` ;
328+ details . willStayUnread = true ;
329+ break ;
330+ case "Discussion" :
331+ details . html_url = `${ notification . repository . html_url } /discussions` ;
332+ break ;
333+ default :
334+ }
335+ return details ;
316336 }
317337 const apiEndpoint = notification . subject . url ;
318338 const response = await fetch ( apiEndpoint , {
Original file line number Diff line number Diff line change @@ -288,13 +288,6 @@ class ClientHandler extends window.Storage {
288288 const notification = notifications . find ( ( n ) => n . id == id ) ;
289289 //TODO get anchor to events after last_read_at for issues/prs
290290 if ( notification ) {
291- //TODO normalize html_url in subjectDetails
292- if ( notification . subject . type === "RepositoryInvitation" ) {
293- return `${ notification . repository . html_url } /invitations` ;
294- }
295- if ( notification . subject . type === "RepositoryVulnerabilityAlert" ) {
296- return `${ notification . repository . html_url } /network/dependencies` ;
297- }
298291 if ( ! notification . subjectDetails . html_url ) {
299292 return notification . repository . html_url ;
300293 }
@@ -303,6 +296,18 @@ class ClientHandler extends window.Storage {
303296 return "" ;
304297 }
305298
299+ async willAutoMarkAsRead ( id ) {
300+ if ( this . client . shouldStayUnread ) {
301+ return false ;
302+ }
303+ const notifications = await this . _getNotifications ( ) ;
304+ const notification = notifications . find ( ( n ) => n . id == id ) ;
305+ if ( notification ?. willStayUnread ) {
306+ return false ;
307+ }
308+ return true ;
309+ }
310+
306311 async getCount ( ) {
307312 const notifications = await this . _getNotifications ( ) ;
308313 return notifications . length ;
You can’t perform that action at this time.
0 commit comments