forked from cwtch.im/cwtch
Merge pull request 'Add RowIndex field to search results for more efficient UI searching' (#526) from search into master
Reviewed-on: cwtch.im/cwtch#526 Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
commit
546180d65e
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue