fix(search): only show channels in the locations if they can be viewed

Partly fixed #10184
This commit is contained in:
Jonathan Rainville 2024-12-11 16:22:14 -05:00
parent acb3b2b31f
commit aaa1ac630c
2 changed files with 12 additions and 5 deletions

View File

@ -71,7 +71,7 @@ proc getChatSubItems(self: Module, chats: seq[ChatDto], categories: seq[Category
var categoryChats: OrderedTable[int, seq[ChatDto]] = initOrderedTable[int, seq[ChatDto]]()
for chatDto in chats:
if chatDto.isHiddenChat:
if not chatDto.canView and not chatDto.missingEncryptionKey:
continue
var chatName = chatDto.name

View File

@ -254,10 +254,6 @@ proc toChatDto*(jsonObj: JsonNode): ChatDto =
discard jsonObj.getProp("readMessagesAtClockValue", result.readMessagesAtClockValue)
discard jsonObj.getProp("unviewedMessagesCount", result.unviewedMessagesCount)
discard jsonObj.getProp("unviewedMentionsCount", result.unviewedMentionsCount)
discard jsonObj.getProp("canPostReactions", result.canPostReactions)
discard jsonObj.getProp("canPost", result.canPost)
discard jsonObj.getProp("canView", result.canView)
discard jsonObj.getProp("viewersCanPostReactions", result.viewersCanPostReactions)
discard jsonObj.getProp("alias", result.alias)
discard jsonObj.getProp("muted", result.muted)
discard jsonObj.getProp("categoryId", result.categoryId)
@ -286,6 +282,17 @@ proc toChatDto*(jsonObj: JsonNode): ChatDto =
(chatTypeInt >= ord(low(ChatType)) or chatTypeInt <= ord(high(ChatType)))):
result.chatType = ChatType(chatTypeInt)
# Default those properties to true as they are only provided for community chats
# To be refactored with https://github.com/status-im/status-desktop/issues/11694
result.canPostReactions = true
result.canPost = true
result.canView = true
result.viewersCanPostReactions = true
discard jsonObj.getProp("canPostReactions", result.canPostReactions)
discard jsonObj.getProp("canPost", result.canPost)
discard jsonObj.getProp("canView", result.canView)
discard jsonObj.getProp("viewersCanPostReactions", result.viewersCanPostReactions)
var chatImage: string
discard jsonObj.getProp("image", chatImage)
if (result.chatType == ChatType.PrivateGroupChat and len(chatImage) > 0):