fix(search): add community to channelGroups and fix channel search
Fixes #7017
This commit is contained in:
parent
cfef7dc443
commit
8624b3ae9a
|
@ -157,7 +157,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
|
||||||
for channelGroup in channelGroups:
|
for channelGroup in channelGroups:
|
||||||
let isCommunity = channelGroup.channelGroupType == ChannelGroupType.Community
|
let isCommunity = channelGroup.channelGroupType == ChannelGroupType.Community
|
||||||
if(self.controller.searchLocation().len == 0 and
|
if(self.controller.searchLocation().len == 0 and
|
||||||
channelGroup.name.toLower.startsWith(searchTerm)):
|
channelGroup.name.toLower.contains(searchTerm)):
|
||||||
let item = result_item.initItem(
|
let item = result_item.initItem(
|
||||||
channelGroup.id,
|
channelGroup.id,
|
||||||
content="",
|
content="",
|
||||||
|
@ -180,7 +180,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
|
||||||
items.add(item)
|
items.add(item)
|
||||||
|
|
||||||
# Add channels
|
# Add channels
|
||||||
if(self.controller.searchSubLocation().len == 0 and self.controller.searchLocation().len == 0 or
|
if((self.controller.searchSubLocation().len == 0 and self.controller.searchLocation().len == 0) or
|
||||||
self.controller.searchLocation() == channelGroup.id):
|
self.controller.searchLocation() == channelGroup.id):
|
||||||
for chatDto in channelGroup.chats:
|
for chatDto in channelGroup.chats:
|
||||||
var chatName = chatDto.name
|
var chatName = chatDto.name
|
||||||
|
@ -197,7 +197,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
|
||||||
if(chatName.startsWith("@")):
|
if(chatName.startsWith("@")):
|
||||||
rawChatName = chatName[1 ..^ 1]
|
rawChatName = chatName[1 ..^ 1]
|
||||||
|
|
||||||
if(rawChatName.toLower.startsWith(searchTerm)):
|
if(rawChatName.toLower.contains(searchTerm)):
|
||||||
let item = result_item.initItem(
|
let item = result_item.initItem(
|
||||||
chatDto.id,
|
chatDto.id,
|
||||||
content="",
|
content="",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import NimQml, Tables, json, sequtils, strformat, chronicles, os, std/algorithm,
|
||||||
import ./dto/chat as chat_dto
|
import ./dto/chat as chat_dto
|
||||||
import ../message/dto/message as message_dto
|
import ../message/dto/message as message_dto
|
||||||
import ../activity_center/dto/notification as notification_dto
|
import ../activity_center/dto/notification as notification_dto
|
||||||
|
import ../community/dto/community as community_dto
|
||||||
import ../contacts/service as contact_service
|
import ../contacts/service as contact_service
|
||||||
import ../../../backend/chat as status_chat
|
import ../../../backend/chat as status_chat
|
||||||
import ../../../backend/group_chat as status_group_chat
|
import ../../../backend/group_chat as status_group_chat
|
||||||
|
@ -115,6 +116,7 @@ QtObject:
|
||||||
|
|
||||||
# Forward declarations
|
# Forward declarations
|
||||||
proc updateOrAddChat*(self: Service, chat: ChatDto)
|
proc updateOrAddChat*(self: Service, chat: ChatDto)
|
||||||
|
proc updateOrAddChannelGroup*(self: Service, channelGroup: ChannelGroupDto)
|
||||||
|
|
||||||
proc doConnect(self: Service) =
|
proc doConnect(self: Service) =
|
||||||
self.events.on(SignalType.Message.event) do(e: Args):
|
self.events.on(SignalType.Message.event) do(e: Args):
|
||||||
|
@ -133,6 +135,11 @@ QtObject:
|
||||||
for clearedHistoryDto in receivedData.clearedHistories:
|
for clearedHistoryDto in receivedData.clearedHistories:
|
||||||
self.events.emit(SIGNAL_CHAT_HISTORY_CLEARED, ChatArgs(chatId: clearedHistoryDto.chatId))
|
self.events.emit(SIGNAL_CHAT_HISTORY_CLEARED, ChatArgs(chatId: clearedHistoryDto.chatId))
|
||||||
|
|
||||||
|
# Handling community updates
|
||||||
|
if (receivedData.communities.len > 0):
|
||||||
|
for community in receivedData.communities:
|
||||||
|
self.updateOrAddChannelGroup(community.toChannelGroupDto())
|
||||||
|
|
||||||
proc sortPersonnalChatAsFirst[T, D](x, y: (T, D)): int =
|
proc sortPersonnalChatAsFirst[T, D](x, y: (T, D)): int =
|
||||||
if (x[1].channelGroupType == Personal): return -1
|
if (x[1].channelGroupType == Personal): return -1
|
||||||
if (y[1].channelGroupType == Personal): return 1
|
if (y[1].channelGroupType == Personal): return 1
|
||||||
|
@ -196,6 +203,11 @@ QtObject:
|
||||||
else:
|
else:
|
||||||
self.channelGroups[channelGroupId].chats[index] = chat
|
self.channelGroups[channelGroupId].chats[index] = chat
|
||||||
|
|
||||||
|
proc updateOrAddChannelGroup*(self: Service, channelGroup: ChannelGroupDto) =
|
||||||
|
self.channelGroups[channelGroup.id] = channelGroup
|
||||||
|
for chat in channelGroup.chats:
|
||||||
|
self.updateOrAddChat(chat)
|
||||||
|
|
||||||
proc parseChatResponse*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) =
|
proc parseChatResponse*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) =
|
||||||
var chats: seq[ChatDto] = @[]
|
var chats: seq[ChatDto] = @[]
|
||||||
var messages: seq[MessageDto] = @[]
|
var messages: seq[MessageDto] = @[]
|
||||||
|
|
Loading…
Reference in New Issue