@@ -7,47 +7,44 @@ import { appId } from './helpers';
77
88// import url = require('url');
99import WinRTNotifier = require( 'electron-windows-notifications' ) ;
10-
10+ import DefaultNotification = require ( './default-notification' ) ;
1111import ConfigUtil = require( '../utils/config-util' ) ;
1212
13+ function showNotif ( title : string , opts : NotificationOptions ) : void {
14+ const profilePic = "F:\\GitHub\\zulip-desktop\\app\\renderer\\img\\icon.png" ;
15+ const notification2 = new WinRTNotifier . ToastNotification ( {
16+ appId,
17+ template : `<toast launch="message">
18+ <visual>
19+ <binding template="ToastGeneric">
20+ <text hint-maxLines="1">%s</text>
21+ <image placement="appLogoOverride" hint-crop="circle" src="%s"/>
22+ <text>%s</text>
23+ </binding>
24+ </visual>
25+ <actions>
26+ <input id="reply" type="text" placeHolderContent="Type a reply"/>
27+ <action hint-inputId="" activationType="background" content="Reply" arguments="send" />
28+ <action activationType="background" content="Dismiss" arguments="" />
29+ </actions>
30+ </toast>` ,
31+ strings : [ title , profilePic , opts . body ]
32+ // tag: opts.tag
33+ } ) ;
34+ notification2 . show ( ) ;
35+ }
1336
14- class WinRTNotification {
15- tag : string ;
16-
37+ class WinRTNotification extends DefaultNotification {
38+ // tag: string;
1739 constructor ( title : string , opts : NotificationOptions ) {
18- // const silent: boolean = ConfigUtil.getConfigItem('silent') || false;
19- // const { host, protocol } = location;
20- // const { icon } = opts;
21- // const profilePic = url.resolve(`${protocol}//${host}`, icon);
22- const profilePic = "F:\\GitHub\\zulip-desktop\\app\\renderer\\img\\icon.png" ;
23- // const notifTitle = title;
24- this . tag = opts . tag ;
40+ opts . silent = true ;
41+ super ( title , opts ) ;
42+ // this.tag = opts.tag;
2543 opts . silent = false ;
26- console . log ( 'Executed' ) ;
2744 console . log ( title ) ;
2845 console . log ( opts ) ;
29- const notification2 = new WinRTNotifier . ToastNotification ( {
30- appId,
31- template : `<toast launch="message">
32- <visual>
33- <binding template="ToastGeneric">
34- <text hint-maxLines="1">%s</text>
35- <image placement="appLogoOverride" hint-crop="circle" src="%s"/>
36- <text>%s</text>
37- </binding>
38- </visual>
39- <actions>
40- <input id="reply" type="text" placeHolderContent="Type a reply"/>
41- <action hint-inputId="" activationType="background" content="Reply" arguments="send" />
42- <action activationType="background" content="Dismiss" arguments="" />
43- </actions>
44- </toast>` ,
45- strings : [ 'Sender' , profilePic , 'Message' ]
46- } ) ;
47- console . log ( "X123" ) ;
48- notification2 . show ( ) ;
46+ showNotif ( title , opts ) ;
4947 console . log ( "Created notification" ) ;
50- // notification.show();
5148 }
5249
5350 static requestPermission ( ) : void {
@@ -58,6 +55,15 @@ class WinRTNotification {
5855 static get permission ( ) : NotificationPermission {
5956 return ConfigUtil . getConfigItem ( 'showNotification' ) ? 'granted' : 'denied' ;
6057 }
58+
59+ close ( ) : void {
60+ return ; // eslint-disable-line no-useless-return
61+ }
62+
63+ // show(): void{
64+ // this.notification2.show();
65+ // return;
66+ // }
6167}
6268
6369module . exports = WinRTNotification ;
0 commit comments