File tree Expand file tree Collapse file tree
Dechat/dex_with_fiat_frontend/src/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,9 +142,11 @@ export function searchChatHistory(
142142 const hasWallet = walletAddress . trim ( ) . length > 0 ;
143143 const hasDate = dateFrom . trim ( ) . length > 0 || dateTo . trim ( ) . length > 0 ;
144144
145- // If no filters at all, return empty
145+ const totalMessages = sessions . reduce ( ( sum , s ) => sum + s . messages . length , 0 ) ;
146+
147+ // If no filters at all, return early with accurate counts but no matches.
146148 if ( ! hasKeyword && ! hasWallet && ! hasDate ) {
147- return { matches : [ ] , totalSessions : sessions . length , totalMessages : 0 } ;
149+ return { matches : [ ] , totalSessions : sessions . length , totalMessages } ;
148150 }
149151
150152 const matches : MessageMatch [ ] = [ ] ;
@@ -175,6 +177,5 @@ export function searchChatHistory(
175177 }
176178 }
177179
178- const totalMessages = sessions . reduce ( ( sum , s ) => sum + s . messages . length , 0 ) ;
179180 return { matches, totalSessions : sessions . length , totalMessages } ;
180181}
You can’t perform that action at this time.
0 commit comments