Add RowIndex field to search results for more efficient UI searching
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2023-07-27 10:45:01 -07:00 committed by Gitea
parent b27229091a
commit 9dbc398690
2 changed files with 3 additions and 1 deletions

View File

@ -276,6 +276,7 @@ const (
EventID = Field("EventID")
EventContext = Field("EventContext")
Index = Field("Index")
RowIndex = Field("RowIndex")
ContentHash = Field("ContentHash")
// Handle denotes a contact handle of any type.

View File

@ -844,7 +844,8 @@ func (cp *cwtchPeer) doSearch(ctx context.Context, searchID string, pattern stri
}
for _, matchingMessage := range matchingMessages {
// publish this search result...
cp.PublishEvent(event.NewEvent(event.SearchResult, map[event.Field]string{event.SearchID: searchID, event.ConversationID: strconv.Itoa(conversation.ID), event.Index: strconv.Itoa(matchingMessage.ID)}))
index, _ := cp.storage.GetRowNumberByMessageID(conversation.ID, 0, matchingMessage.ID)
cp.PublishEvent(event.NewEvent(event.SearchResult, map[event.Field]string{event.SearchID: searchID, event.RowIndex: strconv.Itoa(index), event.ConversationID: strconv.Itoa(conversation.ID), event.Index: strconv.Itoa(matchingMessage.ID)}))
log.Debugf("found matching message: %q", matchingMessage)
}
}