@@ -85,9 +85,10 @@ function searchPastChats(query) {
8585 let matchesInChatCount = 0 ;
8686 let first_msg = '' ;
8787 chat . msg . forEach ( msg => {
88- let cnt = msg . content . normalize ( 'NFD' ) . replace ( / [ \u0300 - \u036f ] / g, '' ) . trim ( ) ;
88+ let msg_cnt = msg ?. content ?? '' ;
89+ let cnt = msg_cnt . normalize ( 'NFD' ) . replace ( / [ \u0300 - \u036f ] / g, '' ) . trim ( ) ;
8990 if ( first_msg === '' ) {
90- first_msg = msg . content ;
91+ first_msg = msg_cnt ;
9192 }
9293 if ( cnt ) {
9394 const currentMatches = cnt . match ( regex ) ;
@@ -164,12 +165,12 @@ input_search.onkeyup = () => {
164165 }
165166 let open_chat = document . createElement ( 'div' ) ;
166167 open_chat . setAttribute ( 'chat_id' , result . id ) ;
167- open_chat . innerHTML = result . first_msg ;
168+ open_chat . innerText = result . first_msg ;
168169 open_chat . querySelector ( 'details' ) ?. remove ( ) ;
169170 if ( open_chat . innerText . length > 137 ) {
170- open_chat . innerHTML = open_chat . innerText . substring ( 0 , 133 ) + '...' ;
171+ open_chat . innerText = open_chat . innerText . substring ( 0 , 133 ) + '...' ;
171172 }
172- open_chat . innerHTML += date_info ;
173+ open_chat . innerText += date_info ;
173174 open_chat . classList . add ( 'result_item' ) ;
174175 open_chat . setAttribute ( 'onclick' , `openOldChat(${ result . id } )` ) ;
175176 div_show . appendChild ( open_chat ) ;
0 commit comments