@@ -37,7 +37,6 @@ const useChannelStore = defineStore('channel', () => {
3737 }
3838
3939 const activeTarget = ref ( '#general' ) ;
40-
4140 function changeActiveChannel ( channel : string ) {
4241 activeTarget . value = channel ;
4342 }
@@ -55,10 +54,14 @@ const useChannelStore = defineStore('channel', () => {
5554 }
5655
5756 irc . client . part ( channel ) ;
58- channelMap . delete ( channel ) ;
57+ const otherChannels = channelList . value . filter ( ( c ) => c !== channel ) ;
58+ if ( otherChannels . length > 0 ) {
59+ changeActiveChannel ( otherChannels [ 0 ] ) ;
60+ channelMap . delete ( channel ) ;
61+ }
5962 }
6063
61- async function addMessageNotification ( channelName : string , message : Message ) {
64+ async function sendMessageNotification ( channelName : string , message : Message ) {
6265 const user = userList . getUser ( message . nick ) ;
6366 const channel = getChannel ( channelName ) ;
6467 channel . hasNotification = true ;
@@ -163,13 +166,17 @@ const useChannelStore = defineStore('channel', () => {
163166 log . debug ( 'new message:' , newMessage ) ;
164167 channel . messages . push ( newMessage ) ;
165168
169+ if ( typeof newMessage . tags . batch === 'string' ) {
170+ // Don't trigger notifications on chat history playback
171+ return ;
172+ }
166173 // If the user has allows for notifications on channel or keywords
167174 // Display/send notifications if user is in another channel or has browser blurred
168175 // Otherwise mark channel as read if user is actively viewing the channel
169176 const isOtherChannel = channel . name !== activeTarget . value ;
170177 if ( ! isFocusedWindow || isOtherChannel ) {
171178 if ( channel . notificationsEnabled ) {
172- addMessageNotification ( channel . name , newMessage ) ;
179+ sendMessageNotification ( channel . name , newMessage ) ;
173180
174181 if (
175182 message . toLocaleLowerCase ( ) . includes ( irc . currentUser . username . toLocaleLowerCase ( ) )
@@ -179,7 +186,7 @@ const useChannelStore = defineStore('channel', () => {
179186 } else if (
180187 notifications . notificationKeywords . some ( ( keyword ) => message . includes ( keyword ) )
181188 ) {
182- addMessageNotification ( channel . name , newMessage ) ;
189+ sendMessageNotification ( channel . name , newMessage ) ;
183190 }
184191 } else {
185192 markAsRead ( channel . name ) ;
@@ -188,6 +195,7 @@ const useChannelStore = defineStore('channel', () => {
188195 } ,
189196 ) ;
190197
198+ // TODO: Add addSystemMessage method
191199 return {
192200 channelList,
193201 activeChannel : computed ( ( ) => readonly ( getChannel ( activeTarget . value ) ) ) ,
0 commit comments