@@ -47,7 +47,7 @@ const useChannelStore = defineStore('channel', () => {
4747 }
4848 const newChannel = irc . client . channel ( channel ) ;
4949 newChannel . updateUsers ( ) ;
50- getChannel ( channel ) ;
50+ changeActiveChannel ( channel ) ;
5151 }
5252 function leaveChannel ( channel : string ) {
5353 if ( ! irc . client ) {
@@ -63,19 +63,17 @@ const useChannelStore = defineStore('channel', () => {
6363 const channel = getChannel ( channelName ) ;
6464 channel . hasNotification = true ;
6565
66- try {
67- const notification = await notifications . sendNotification (
68- `New message in ${ channel . name } ` ,
69- `${ user . username } : ${ message . message } ` ,
70- `new-message-${ message . target } ` ,
71- ) ;
72- notification ?. addEventListener ( 'click' , ( ) => {
73- // View channel if notification is clicked
66+ notifications . sendNotification (
67+ {
68+ title : `New message in ${ channel . name } ` ,
69+ body : `${ user . username } : ${ message . message } ` ,
70+ tag : `new-message-${ message . target } ` ,
71+ } ,
72+ ( ) => {
73+ // Open channel if notification is clicked
7474 changeActiveChannel ( channel . name ) ;
75- } ) ;
76- } catch ( err ) {
77- log . error ( 'Notification error:' , err ) ;
78- }
75+ } ,
76+ ) ;
7977 }
8078
8179 function markAsRead ( channelName : string ) {
@@ -105,13 +103,16 @@ const useChannelStore = defineStore('channel', () => {
105103 }
106104
107105 client
108- . on ( 'action ' , ( event ) => {
109- log . debug ( 'Action ' , event ) ;
110- // TODO: Use typing client-tag
106+ . on ( 'tagmsg ' , ( event ) => {
107+ log . debug ( 'TAGMSG ' , event ) ;
108+ // TODO: Use '+ typing' client-tag
111109 // See https://ircv3.net/specs/client-tags/typing
112110 } )
111+ . on ( 'action' , ( event ) => {
112+ log . debug ( 'ACTION' , event ) ;
113+ } )
113114 . on ( 'notice' , ( event ) => {
114- log . debug ( 'Notice ' , event ) ;
115+ log . debug ( 'NOTICE ' , event ) ;
115116 } )
116117 . on ( 'privmsg' , ( event ) => {
117118 log . debug ( 'PRIVMSG' , event ) ;
@@ -123,17 +124,19 @@ const useChannelStore = defineStore('channel', () => {
123124
124125 const highlightedMessage = highlightKeywords ( message ) ;
125126 const newMessage : Message = {
126- // TODO: Read from server time, if available
127- time : new Date ( ) ,
127+ id : event . tags . msgid ?? crypto . randomUUID ( ) ,
128+ time : event . time ?? Date . now ( ) ,
128129 starred : false ,
129130 message : highlightedMessage ,
130131 target,
131132 nick,
132- type : 'message ' ,
133+ type : 'privmsg ' ,
133134 tags : tags ?? { } ,
134135 } ;
135- // TODO: Cap messages per channel (50)
136- log . debug ( newMessage ) ;
136+ // TODO: Cap messages per channel (100)
137+ // TODO: Sort-insert messages based on `time` value
138+ // TODO: Prevent duplicate message insertions with `id` value
139+ log . debug ( 'new message:' , newMessage ) ;
137140 channel . messages . push ( newMessage ) ;
138141
139142 // If the user has allows for notifications on channel or keywords
0 commit comments