File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -63,19 +63,22 @@ const Chat = () => {
6363 const scrollToLastMessage = useCallback ( async ( ) => {
6464 const lastElement = chatMessagesRef . current
6565 ?. lastChild as HTMLDivElement ;
66- lastElement . scrollIntoView ( {
67- behavior : "smooth" ,
68- block : "end" ,
69- } ) ;
7066
71- if ( ! lastElement . classList . contains ( "notification-showed" ) ) {
72- const userName = lastElement . childNodes [ 0 ] ?. textContent ?. trim ( ) ;
73- const message = lastElement . childNodes [ 1 ] ?. textContent ?. trim ( ) ;
67+ if ( lastElement ) {
68+ lastElement . scrollIntoView ( {
69+ behavior : "smooth" ,
70+ block : "end" ,
71+ } ) ;
7472
75- if ( userName && message ) {
76- await notify ( userName , message ) ;
73+ if ( ! lastElement . classList . contains ( "notification-showed" ) ) {
74+ const userName = lastElement . childNodes [ 0 ] ?. textContent ?. trim ( ) ;
75+ const message = lastElement . childNodes [ 1 ] ?. textContent ?. trim ( ) ;
7776
78- lastElement . classList . add ( "notification-showed" ) ;
77+ if ( userName && message ) {
78+ await notify ( userName , message ) ;
79+
80+ lastElement . classList . add ( "notification-showed" ) ;
81+ }
7982 }
8083 }
8184 } , [ notify ] ) ;
You can’t perform that action at this time.
0 commit comments