Skip to content

Commit 739b4c2

Browse files
authored
Merge pull request #1296 from Mercy017/fix/issues-1225-1221-1223-1220-all
fix(frontend): resolve stale closures and memory leaks across chat frontend
2 parents a15fdd6 + b7673da commit 739b4c2

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Dechat/dex_with_fiat_frontend/src/lib/chatSearch.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)