feature(@desktop/chat): implement search on sqlcipher (status-go side)

Searching messages by some term for a specific channel is added on the side of status-go and an
appropriate part on the side of nim is developed accordingly.

Fixes: #2912
This commit is contained in:
Sale Djenic 2021-07-21 16:33:43 +02:00 committed by Iuri Matias
parent de661459cb
commit 74d868ab92
8 changed files with 39 additions and 11 deletions

View File

@ -52,3 +52,4 @@ QtObject:
## displaying already filtered messages (for example filtered response from DB) ## displaying already filtered messages (for example filtered response from DB)
self.clear(false) self.clear(false)
self.add(messages) self.add(messages)

View File

@ -500,10 +500,39 @@ QtObject:
QtProperty[QVariant] searchResultMessageModel: QtProperty[QVariant] searchResultMessageModel:
read = getSearchResultMessageModel read = getSearchResultMessageModel
proc onSearchMessages*(self: MessageView, response: string) {.slot.} =
let responseObj = response.parseJson
if (responseObj.kind != JObject):
error "search messages response is not an json object"
return
let chatId = if(responseObj.contains("chatId")): responseObj{"chatId"}.getStr else : ""
if (chatId.len == 0):
error "search messages response either doesn't contain chatId or it is empty"
return
let messagesObj = if(responseObj.contains("messages")): responseObj{"messages"} else: newJObject()
if (messagesObj.kind != JObject):
error "search messages response either doesn't contain messages object or it is empty"
return
let (cursor, messages) = status_chat.parseChatMessagesResponse(messagesObj)
self.searchResultMessageModel.setFilteredMessages(messages)
proc searchMessages*(self: MessageView, searchTerm: string) {.slot.} = proc searchMessages*(self: MessageView, searchTerm: string) {.slot.} =
# channelId is used here only to support message search in currently selected channel if (searchTerm.len == 0):
self.searchResultMessageModel.clear(false)
return
# chatId is used here only to support message search in currently selected channel
# later when we decide to apply message search over multiple channels MessageListProxyModel # later when we decide to apply message search over multiple channels MessageListProxyModel
# will be updated to support setting list of sourcer messages. # will be updated to support setting list of sourcer messages.
let channelId = self.channelView.activeChannel.id let chatId = self.channelView.activeChannel.id
self.searchResultMessageModel.setSourceMessages(self.messageList[channelId].messages) let slot = SlotArg(
self.searchResultMessageModel.setFilter(searchTerm, false) vptr: cast[ByteAddress](self.vptr),
slot: "onSearchMessages"
)
self.status.chat.asyncSearchMessages(slot, chatId, searchTerm, false)

@ -1 +1 @@
Subproject commit 7e03daeaf9bf4e1614d5507400b3d9a0ac016bc0 Subproject commit 6c67aaf3a3031af92931dce9673418e81f80749f

View File

@ -218,8 +218,6 @@ Popup {
prevMessageIndex: -1 prevMessageIndex: -1
prevMsgTimestamp: "" prevMsgTimestamp: ""
} }
} }
} }
} }

2
vendor/DOtherSide vendored

@ -1 +1 @@
Subproject commit a838753904615610667e704efec5864e0d27e7c2 Subproject commit eaa394d711f757b859030349aeaf41a10e1bad2b

@ -1 +1 @@
Subproject commit f4463f3955a96e162e9881b73ba02f819e0374a4 Subproject commit f1ec58561d7b48f6c8b664f3806fd8a113164fba

2
vendor/nimqml vendored

@ -1 +1 @@
Subproject commit 8ca765ca11a9fde6a43d60289afcea312d3e6ed8 Subproject commit 65fa68c244fa52037de652520755430ec65c77df

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit c4a71f813a783e310b1c8ca59d2390a8d76f6a0c Subproject commit dd66d0f49ca9158a05fa4294419f9a6f322aa591