First cut of Conversation Search #518

Merged
sarah merged 5 commits from conversation_search into master 2023-07-13 19:39:41 +00:00
1 changed files with 4 additions and 1 deletions
Showing only changes of commit 75eb49d6ee - Show all commits

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...
}