diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 62f1d4531a..57e17008b1 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -695,12 +695,12 @@ proc addNewChat( if category.id == "": error "No category found for chat", chatName=chatDto.name, categoryId=chatDto.categoryId else: - categoryOpened = category.categoryOpened + categoryOpened = not category.collapsed categoryPosition = category.position # TODO: This call will update the model for each category in channels which is not # preferable. Please fix-me in https://github.com/status-im/status-desktop/issues/14431 - self.view.chatsModel().changeCategoryOpened(category.id, category.categoryOpened) + self.view.chatsModel().changeCategoryOpened(category.id, categoryOpened) var canPostReactions = true var hideIfPermissionsNotMet = false @@ -1394,7 +1394,7 @@ method toggleCollapsedCommunityCategory*(self: Module, categoryId: string, colla self.controller.toggleCollapsedCommunityCategory(categoryId, collapsed) method onToggleCollapsedCommunityCategory*(self: Module, categoryId: string, collapsed: bool) = - self.view.chatsModel().changeCategoryOpened(categoryId, collapsed) + self.view.chatsModel().changeCategoryOpened(categoryId, not collapsed) method reorderCommunityChat*(self: Module, categoryId: string, chatId: string, toPosition: int) = self.controller.reorderCommunityChat(categoryId, chatId, toPosition + 1) diff --git a/src/app_service/service/chat/dto/chat.nim b/src/app_service/service/chat/dto/chat.nim index 92af5a7967..112f0a52e2 100644 --- a/src/app_service/service/chat/dto/chat.nim +++ b/src/app_service/service/chat/dto/chat.nim @@ -25,7 +25,7 @@ type Category* = object id*: string name*: string position*: int - categoryOpened*: bool + collapsed*: bool type Permission* = object @@ -189,7 +189,7 @@ proc toCategory*(jsonObj: JsonNode): Category = discard jsonObj.getProp("id", result.id) discard jsonObj.getProp("name", result.name) discard jsonObj.getProp("position", result.position) - discard jsonObj.getProp("categoryOpened", result.categoryOpened) + discard jsonObj.getProp("collapsed", result.collapsed) proc toChatMember*(jsonObj: JsonNode, memberId: string): ChatMember = # Parse status-go "Member" type diff --git a/src/app_service/service/community/dto/community.nim b/src/app_service/service/community/dto/community.nim index 21b9e73bbb..39b81f390d 100644 --- a/src/app_service/service/community/dto/community.nim +++ b/src/app_service/service/community/dto/community.nim @@ -391,10 +391,13 @@ proc toCommunityMembershipRequestDto*(jsonObj: JsonNode): CommunityMembershipReq discard jsonObj.getProp("communityId", result.communityId) discard jsonObj.getProp("our", result.our) -proc toCategoryDto*(jsonObj: JsonNode): Category = +proc toCollapsedCategoryDto*(jsonObj: JsonNode, isCollapsed: bool = false): Category = result = Category() discard jsonObj.getProp("categoryId", result.id) - discard jsonObj.getProp("collapsed", result.categoryOpened) + # The CollapsedCommunityCategories API only returns **collapsed** categories. + # So if a category is **not** collapsed, it's not in the list + # The collapsed property on the json is always false + result.collapsed = true proc toCommunityDto*(jsonObj: JsonNode): CommunityDto = result = CommunityDto() @@ -499,16 +502,16 @@ proc toCommunitySettingsDto*(jsonObj: JsonNode): CommunitySettingsDto = discard jsonObj.getProp("historyArchiveSupportEnabled", result.historyArchiveSupportEnabled) proc parseCommunities*(response: JsonNode, categories: seq[Category]): seq[CommunityDto] = - var categoryMap = initTable[string, bool]() + var categoryCollapsedMap = initTable[string, bool]() for category in categories: - categoryMap[category.id] = true + categoryCollapsedMap[category.id] = true for communityNode in response["result"].getElems(): var community = communityNode.toCommunityDto() for category in community.categories.mitems: - if categoryMap.hasKey(category.id): - category.categoryOpened = true + if categoryCollapsedMap.hasKey(category.id): + category.collapsed = true result.add(community) proc parseKnownCuratedCommunities(jsonCommunities: JsonNode): seq[CommunityDto] = diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 72be14b962..f7e849551b 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -817,7 +817,7 @@ QtObject: let collapsedCommunityCategories = responseObj["collapsedCommunityCategories"] if collapsedCommunityCategories{"result"}.kind != JNull: for jsonCategory in collapsedCommunityCategories["result"]: - categories.add(jsonCategory.toCategoryDto()) + categories.add(jsonCategory.toCollapsedCategoryDto()) # All communities let communities = parseCommunities(responseObj["communities"], categories) diff --git a/ui/StatusQ/src/StatusQ/Components/StatusChatList.qml b/ui/StatusQ/src/StatusQ/Components/StatusChatList.qml index bd6633d575..0a6e11a5c6 100644 --- a/ui/StatusQ/src/StatusQ/Components/StatusChatList.qml +++ b/ui/StatusQ/src/StatusQ/Components/StatusChatList.qml @@ -147,11 +147,13 @@ Item { highlighted = true; categoryPopupMenuSlot.item.popup() } else if (mouse.button === Qt.LeftButton) { - root.toggleCollapsedCommunityCategory(model.categoryId, !statusChatListCategoryItem.opened) + // We pass the value for collapsed that we want + // So if opened == true, we want opened == false -> we pass collapsed = true + root.toggleCollapsedCommunityCategory(model.categoryId, statusChatListCategoryItem.opened) } } onToggleButtonClicked: { - root.toggleCollapsedCommunityCategory(model.categoryId, !statusChatListCategoryItem.opened) + root.toggleCollapsedCommunityCategory(model.categoryId, statusChatListCategoryItem.opened) } onMenuButtonClicked: { statusChatListCategoryItem.setupPopup()