Fix maxCount calculation

This commit is contained in:
Sarah Jamie Lewis 2023-06-27 11:54:02 -07:00
parent cfb2335c05
commit 75eb49d6ee
1 changed files with 4 additions and 1 deletions

View File

@ -814,7 +814,7 @@ func (cp *cwtchPeer) doSearch(ctx context.Context, searchID string, pattern stri
if err != nil {
log.Errorf("could not fetch channel count for conversation %d:%d: %s", conversation.ID, 0, err)
}
if maxCount > count {
if count > maxCount {
maxCount = count
}
conversationCount[conversation.ID] = count
@ -850,6 +850,9 @@ func (cp *cwtchPeer) doSearch(ctx context.Context, searchID string, pattern stri
// Note: This should note be used to index a list as the ID is not expected to be tied to absolute position
// in the table (e.g. deleted messages, expired messages, etc.)
func (cp *cwtchPeer) SearchConversations(pattern string) string {
// we need this lock here to prevent weirdness happening when reassigning cp.cancelSearchContext
cp.mutex.Lock()
defer cp.mutex.Unlock()
if cp.cancelSearchContext != nil {
cp.cancelSearchContext() // Cancel any current searches...
}