From 24fa56e3b8876603ade3bef93671680ddbea6fb7 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 27 Jan 2022 12:06:48 -0400 Subject: [PATCH] refactor: add fake category type --- src/app/modules/main/chat_section/model.nim | 4 ++++ src/app/modules/main/chat_section/module.nim | 2 +- src/app_service/service/chat/dto/chat.nim | 1 + ui/imports/utils/Constants.qml | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/modules/main/chat_section/model.nim b/src/app/modules/main/chat_section/model.nim index 5ababab410..62b76b197f 100644 --- a/src/app/modules/main/chat_section/model.nim +++ b/src/app/modules/main/chat_section/model.nim @@ -18,6 +18,7 @@ type Active Position SubItems + IsCategory QtObject: type @@ -77,6 +78,7 @@ QtObject: ModelRole.Active.int:"active", ModelRole.Position.int:"position", ModelRole.SubItems.int:"subItems", + ModelRole.IsCategory.int:"isCategory" }.toTable method data(self: Model, index: QModelIndex, role: int): QVariant = @@ -118,6 +120,8 @@ QtObject: result = newQVariant(item.position) of ModelRole.SubItems: result = newQVariant(item.subItems) + of ModelRole.IsCategory: + result = newQVariant(item.`type` == ChatType.Category.int) proc appendItem*(self: Model, item: Item) = let parentModelIndex = newQModelIndex() diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 3392ad898a..460f4c4543 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -186,7 +186,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter, selectedItemId = cat.id selectedSubItemId = channelItem.id - var categoryItem = initItem(cat.id, cat.name, "", false, "", "", ChatType.Unknown.int, false, + var categoryItem = initItem(cat.id, cat.name, "", false, "", "", ChatType.Category.int, false, hasNotificationPerCategory, notificationsCountPerCategory, false, false, cat.position) categoryItem.prependSubItems(categoryChannels) self.view.chatsModel().appendItem(categoryItem) diff --git a/src/app_service/service/chat/dto/chat.nim b/src/app_service/service/chat/dto/chat.nim index 9f772a163d..685100d29c 100644 --- a/src/app_service/service/chat/dto/chat.nim +++ b/src/app_service/service/chat/dto/chat.nim @@ -12,6 +12,7 @@ type ChatType* {.pure.}= enum Profile = 4, Timeline = 5 CommunityChat = 6 + Category = 9999 type ChatMember* = object id*: string diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index f1ab6eb005..081f75029f 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -53,6 +53,7 @@ QtObject { readonly property int profile: 4 readonly property int timeline: 5 readonly property int communityChat: 6 + readonly property int category: 9999 } readonly property QtObject messageContentType: QtObject {