11import { APPLICATION } from '../../shared/constants' ;
22
3- import type { GitifyNotification } from '../../types' ;
3+ import type { Notification } from '../../typesGitHub' ;
4+ import { isTauriEnvironment } from '../environment' ;
45import { generateGitHubWebUrl } from '../helpers' ;
56
6- export async function raiseNativeNotification (
7- notifications : GitifyNotification [ ] ,
8- ) {
7+ export async function raiseNativeNotification ( notifications : Notification [ ] ) {
8+ if ( ! isTauriEnvironment ( ) ) {
9+ // Browser fallback - use browser notifications
10+ if ( 'Notification' in window && Notification . permission === 'granted' ) {
11+ if ( notifications . length === 1 ) {
12+ const notification = notifications [ 0 ] ;
13+ new Notification ( notification . repository . full_name , {
14+ body : notification . subject . title ,
15+ } ) ;
16+ } else {
17+ new Notification ( APPLICATION . NAME , {
18+ body : `You have ${ notifications . length } notifications` ,
19+ } ) ;
20+ }
21+ }
22+ return ;
23+ }
24+
925 let title : string ;
1026 let body : string ;
1127 let url : string | undefined ;
@@ -14,7 +30,7 @@ export async function raiseNativeNotification(
1430 const notification = notifications [ 0 ] ;
1531 title = window . gitify . platform . isWindows ( )
1632 ? ''
17- : notification . repository . fullName ;
33+ : notification . repository . full_name ;
1834 body = notification . subject . title ;
1935 url = await generateGitHubWebUrl ( notification ) ;
2036 } else {
0 commit comments