refactor(chat-section): new chat/community model applied on the qml side

Changes done on the backend side related to the new chat/channel/categories model
are applied here. Necessary changes done on the `statusq` may be seen in PR-486.

Parts of the code which are not refactored yet are commented out.

Displayed chats/categories/channels since now are using refactored backend.
This commit is contained in:
Sale Djenic 2021-11-26 16:37:57 +01:00
parent c4bb7c7cf2
commit 45d93649b6
26 changed files with 352 additions and 186 deletions

View File

@ -116,8 +116,10 @@ method searchMessages*(self: Controller, searchTerm: string) =
self.messageService.asyncSearchMessages(communities, chats, self.searchTerm, false) self.messageService.asyncSearchMessages(communities, chats, self.searchTerm, false)
method getOneToOneChatNameAndImage*(self: Controller, chatId: string): tuple[name: string, image: string] = method getOneToOneChatNameAndImage*(self: Controller, chatId: string):
tuple[name: string, image: string, isIdenticon: bool] =
return self.chatService.getOneToOneChatNameAndImage(chatId) return self.chatService.getOneToOneChatNameAndImage(chatId)
method getContactNameAndImage*(self: Controller, contactId: string): tuple[name: string, image: string] = method getContactNameAndImage*(self: Controller, contactId: string):
tuple[name: string, image: string, isIdenticon: bool] =
return self.contactsService.getContactNameAndImage(contactId) return self.contactsService.getContactNameAndImage(contactId)

View File

@ -51,9 +51,10 @@ method getChatDetails*(self: AccessInterface, communityId, chatId: string): Chat
method searchMessages*(self: AccessInterface, searchTerm: string) {.base.} = method searchMessages*(self: AccessInterface, searchTerm: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getOneToOneChatNameAndImage*(self: AccessInterface, chatId: string): tuple[name: string, image: string] method getOneToOneChatNameAndImage*(self: AccessInterface, chatId: string):
{.base.} = tuple[name: string, image: string, isIdenticon: bool] {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getContactNameAndImage*(self: AccessInterface, contactId: string): tuple[name: string, image: string] {.base.} = method getContactNameAndImage*(self: AccessInterface, contactId: string):
tuple[name: string, image: string, isIdenticon: bool] {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -6,7 +6,7 @@ export base_item
type type
SubItem* = ref object of BaseItem SubItem* = ref object of BaseItem
proc initSubItem*(value, text, image, icon, iconColor: string = "", isIdenticon: bool = true): SubItem = proc initSubItem*(value, text, image, icon, iconColor: string, isIdenticon: bool): SubItem =
result = SubItem() result = SubItem()
result.setup(value, text, image, icon, iconColor, isIdenticon) result.setup(value, text, image, icon, iconColor, isIdenticon)

View File

@ -78,10 +78,11 @@ proc buildLocationMenuForChat(self: Module): location_menu_item.Item =
for c in displayedChats: for c in displayedChats:
var chatName = c.name var chatName = c.name
var chatImage = c.identicon var chatImage = c.identicon
var isIdenticon = false
if(c.chatType == ChatType.OneToOne): if(c.chatType == ChatType.OneToOne):
(chatName, chatImage) = self.controller.getOneToOneChatNameAndImage(c.id) (chatName, chatImage, isIdenticon) = self.controller.getOneToOneChatNameAndImage(c.id)
let subItem = location_menu_sub_item.initSubItem(c.id, chatName, chatImage, "", c.color, chatImage.len == 0) let subItem = location_menu_sub_item.initSubItem(c.id, chatName, chatImage, "", c.color, isIdenticon)
subItems.add(subItem) subItems.add(subItem)
item.setSubItems(subItems) item.setSubItems(subItems)
@ -157,7 +158,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
for co in communities: for co in communities:
if(self.controller.searchLocation().len == 0 and co.name.toLower.startsWith(self.controller.searchTerm().toLower)): if(self.controller.searchLocation().len == 0 and co.name.toLower.startsWith(self.controller.searchTerm().toLower)):
let item = result_item.initItem(co.id, "", "", co.id, co.name, SEARCH_RESULT_COMMUNITIES_SECTION_NAME, let item = result_item.initItem(co.id, "", "", co.id, co.name, SEARCH_RESULT_COMMUNITIES_SECTION_NAME,
co.images.thumbnail, co.color, "", "", co.images.thumbnail, co.color) co.images.thumbnail, co.color, "", "", co.images.thumbnail, co.color, false)
items.add(item) items.add(item)
@ -169,7 +170,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
if(c.name.toLower.startsWith(self.controller.searchTerm().toLower)): if(c.name.toLower.startsWith(self.controller.searchTerm().toLower)):
let item = result_item.initItem(chatDto.id, "", "", chatDto.id, chatDto.name, let item = result_item.initItem(chatDto.id, "", "", chatDto.id, chatDto.name,
SEARCH_RESULT_CHANNELS_SECTION_NAME, chatDto.identicon, chatDto.color, "", "", chatDto.identicon, chatDto.color, SEARCH_RESULT_CHANNELS_SECTION_NAME, chatDto.identicon, chatDto.color, "", "", chatDto.identicon, chatDto.color,
chatDto.identicon.len > 0) false)
channels.add(item) channels.add(item)
@ -182,8 +183,9 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
for c in displayedChats: for c in displayedChats:
var chatName = c.name var chatName = c.name
var chatImage = c.identicon var chatImage = c.identicon
var isIdenticon = false
if(c.chatType == ChatType.OneToOne): if(c.chatType == ChatType.OneToOne):
(chatName, chatImage) = self.controller.getOneToOneChatNameAndImage(c.id) (chatName, chatImage, isIdenticon) = self.controller.getOneToOneChatNameAndImage(c.id)
var rawChatName = chatName var rawChatName = chatName
if(chatName.startsWith("@")): if(chatName.startsWith("@")):
@ -191,7 +193,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
if(rawChatName.toLower.startsWith(self.controller.searchTerm().toLower)): if(rawChatName.toLower.startsWith(self.controller.searchTerm().toLower)):
let item = result_item.initItem(c.id, "", "", c.id, chatName, SEARCH_RESULT_CHATS_SECTION_NAME, chatImage, let item = result_item.initItem(c.id, "", "", c.id, chatName, SEARCH_RESULT_CHATS_SECTION_NAME, chatImage,
c.color, "", "", chatImage, c.color, chatImage.len > 0) c.color, "", "", chatImage, c.color, isIdenticon)
items.add(item) items.add(item)
@ -204,18 +206,19 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
continue continue
let chatDto = self.controller.getChatDetails("", m.chatId) let chatDto = self.controller.getChatDetails("", m.chatId)
var (senderName, senderImage) = self.controller.getContactNameAndImage(m.`from`) var (senderName, senderImage, senderIsIdenticon) = self.controller.getContactNameAndImage(m.`from`)
if(m.`from` == singletonInstance.userProfile.getPubKey()): if(m.`from` == singletonInstance.userProfile.getPubKey()):
senderName = "You" senderName = "You"
if(chatDto.communityId.len == 0): if(chatDto.communityId.len == 0):
var chatName = chatDto.name var chatName = chatDto.name
var chatImage = chatDto.identicon var chatImage = chatDto.identicon
var isIdenticon = false
if(chatDto.chatType == ChatType.OneToOne): if(chatDto.chatType == ChatType.OneToOne):
(chatName, chatImage) = self.controller.getOneToOneChatNameAndImage(chatDto.id) (chatName, chatImage, isIdenticon) = self.controller.getOneToOneChatNameAndImage(chatDto.id)
let item = result_item.initItem(m.id, m.text, $m.timestamp, m.`from`, senderName, let item = result_item.initItem(m.id, m.text, $m.timestamp, m.`from`, senderName,
SEARCH_RESULT_MESSAGES_SECTION_NAME, senderImage, "", chatName, "", chatImage, chatDto.color, chatImage.len == 0) SEARCH_RESULT_MESSAGES_SECTION_NAME, senderImage, "", chatName, "", chatImage, chatDto.color, isIdenticon)
items.add(item) items.add(item)
else: else:
@ -224,7 +227,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
let item = result_item.initItem(m.id, m.text, $m.timestamp, m.`from`, senderName, let item = result_item.initItem(m.id, m.text, $m.timestamp, m.`from`, senderName,
SEARCH_RESULT_MESSAGES_SECTION_NAME, senderImage, "", community.name, channelName, community.images.thumbnail, SEARCH_RESULT_MESSAGES_SECTION_NAME, senderImage, "", community.name, channelName, community.images.thumbnail,
community.color, community.images.thumbnail.len == 0) community.color, false)
items.add(item) items.add(item)

View File

@ -16,7 +16,7 @@ type Item* = object
badgeIsLetterIdenticon: bool badgeIsLetterIdenticon: bool
proc initItem*(itemId, content, time, titleId, title, sectionName: string, image, color, badgePrimaryText, proc initItem*(itemId, content, time, titleId, title, sectionName: string, image, color, badgePrimaryText,
badgeSecondaryText, badgeImage, badgeIconColor: string = "", badgeIsLetterIdenticon: bool = false): badgeSecondaryText, badgeImage, badgeIconColor: string, badgeIsLetterIdenticon: bool):
Item = Item =
result.itemId = itemId result.itemId = itemId

View File

@ -38,6 +38,15 @@ QtObject:
QtProperty[string] id: QtProperty[string] id:
read = getId read = getId
proc getIsSubItemActive(self: ActiveItem): bool {.slot.} =
if(self.activeSubItem.getId().len > 0):
return true
return false
QtProperty[bool] isSubItemActive:
read = getIsSubItemActive
proc getName(self: ActiveItem): string {.slot.} = proc getName(self: ActiveItem): string {.slot.} =
return self.item.name return self.item.name
@ -68,11 +77,11 @@ QtObject:
QtProperty[int] type: QtProperty[int] type:
read = getType read = getType
proc getHasNotification(self: ActiveItem): bool {.slot.} = proc getHasUnreadMessages(self: ActiveItem): bool {.slot.} =
return self.item.hasNotification return self.item.hasUnreadMessages
QtProperty[bool] hasNotification: QtProperty[bool] hasUnreadMessages:
read = getHasNotification read = getHasUnreadMessages
proc getNotificationCount(self: ActiveItem): int {.slot.} = proc getNotificationCount(self: ActiveItem): int {.slot.} =
return self.item.notificationsCount return self.item.notificationsCount

View File

@ -18,55 +18,73 @@ QtObject:
proc setActiveSubItemData*(self: ActiveSubItem, item: SubItem) = proc setActiveSubItemData*(self: ActiveSubItem, item: SubItem) =
self.item = item self.item = item
proc getId(self: ActiveSubItem): string {.slot.} = proc getId*(self: ActiveSubItem): string {.slot.} =
if(self.item.isNil):
return ""
return self.item.id return self.item.id
QtProperty[string] id: QtProperty[string] id:
read = getId read = getId
proc getName(self: ActiveSubItem): string {.slot.} = proc getName(self: ActiveSubItem): string {.slot.} =
if(self.item.isNil):
return ""
return self.item.name return self.item.name
QtProperty[string] name: QtProperty[string] name:
read = getName read = getName
proc getIcon(self: ActiveSubItem): string {.slot.} = proc getIcon(self: ActiveSubItem): string {.slot.} =
if(self.item.isNil):
return ""
return self.item.icon return self.item.icon
QtProperty[string] icon: QtProperty[string] icon:
read = getIcon read = getIcon
proc getColor(self: ActiveSubItem): string {.slot.} = proc getColor(self: ActiveSubItem): string {.slot.} =
if(self.item.isNil):
return ""
return self.item.color return self.item.color
QtProperty[string] color: QtProperty[string] color:
read = getColor read = getColor
proc getDescription(self: ActiveSubItem): string {.slot.} = proc getDescription(self: ActiveSubItem): string {.slot.} =
if(self.item.isNil):
return ""
return self.item.description return self.item.description
QtProperty[string] description: QtProperty[string] description:
read = getDescription read = getDescription
proc getHasNotification(self: ActiveSubItem): bool {.slot.} = proc getHasUnreadMessages(self: ActiveSubItem): bool {.slot.} =
return self.item.hasNotification if(self.item.isNil):
return false
return self.item.hasUnreadMessages
QtProperty[bool] hasNotification: QtProperty[bool] hasUnreadMessages:
read = getHasNotification read = getHasUnreadMessages
proc getNotificationCount(self: ActiveSubItem): int {.slot.} = proc getNotificationCount(self: ActiveSubItem): int {.slot.} =
if(self.item.isNil):
return 0
return self.item.notificationsCount return self.item.notificationsCount
QtProperty[int] notificationCount: QtProperty[int] notificationCount:
read = getNotificationCount read = getNotificationCount
proc getMuted(self: ActiveSubItem): bool {.slot.} = proc getMuted(self: ActiveSubItem): bool {.slot.} =
if(self.item.isNil):
return false
return self.item.muted return self.item.muted
QtProperty[bool] muted: QtProperty[bool] muted:
read = getMuted read = getMuted
proc getPosition(self: ActiveSubItem): int {.slot.} = proc getPosition(self: ActiveSubItem): int {.slot.} =
if(self.item.isNil):
return 0
return self.item.position return self.item.position
QtProperty[int] position: QtProperty[int] position:

View File

@ -3,31 +3,34 @@ type
id: string id: string
name: string name: string
icon: string icon: string
isIdenticon: bool
color: string color: string
description: string description: string
hasNotification: bool hasUnreadMessages: bool
notificationsCount: int notificationsCount: int
muted: bool muted: bool
active: bool active: bool
position: int position: int
proc setup*(self: BaseItem, id, name, icon, color, description: string, hasNotification: bool, notificationsCount: int, proc setup*(self: BaseItem, id, name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool,
muted, active: bool, position: int) = notificationsCount: int, muted, active: bool, position: int) =
self.id = id self.id = id
self.name = name self.name = name
self.icon = icon self.icon = icon
self.isIdenticon = isIdenticon
self.color = color self.color = color
self.description = description self.description = description
self.hasNotification = hasNotification self.hasUnreadMessages = hasUnreadMessages
self.notificationsCount = notificationsCount self.notificationsCount = notificationsCount
self.muted = muted self.muted = muted
self.active = active self.active = active
self.position = position self.position = position
proc initBaseItem*(id, name, icon, color, description: string, hasNotification: bool, notificationsCount: int, proc initBaseItem*(id, name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool,
muted, active: bool, position: int): BaseItem = notificationsCount: int, muted, active: bool, position: int): BaseItem =
result = BaseItem() result = BaseItem()
result.setup(id, name, icon, color, description, hasNotification, notificationsCount, muted, active, position) result.setup(id, name, icon, isIdenticon, color, description, hasUnreadMessages, notificationsCount, muted, active,
position)
proc delete*(self: BaseItem) = proc delete*(self: BaseItem) =
discard discard
@ -41,17 +44,20 @@ method name*(self: BaseItem): string {.inline base.} =
method icon*(self: BaseItem): string {.inline base.} = method icon*(self: BaseItem): string {.inline base.} =
self.icon self.icon
method isIdenticon*(self: BaseItem): bool {.inline base.} =
self.isIdenticon
method color*(self: BaseItem): string {.inline base.} = method color*(self: BaseItem): string {.inline base.} =
self.color self.color
method description*(self: BaseItem): string {.inline base.} = method description*(self: BaseItem): string {.inline base.} =
self.description self.description
method hasNotification*(self: BaseItem): bool {.inline base.} = method hasUnreadMessages*(self: BaseItem): bool {.inline base.} =
self.hasNotification self.hasUnreadMessages
method `hasNotification=`*(self: var BaseItem, value: bool) {.inline base.} = method `hasUnreadMessages=`*(self: var BaseItem, value: bool) {.inline base.} =
self.hasNotification = value self.hasUnreadMessages = value
method notificationsCount*(self: BaseItem): int {.inline base.} = method notificationsCount*(self: BaseItem): int {.inline base.} =
self.notificationsCount self.notificationsCount

View File

@ -33,8 +33,6 @@ method delete*(self: Module) =
self.controller.delete self.controller.delete
method load*(self: Module) = method load*(self: Module) =
singletonInstance.engine.setRootContextProperty("inputAreaModule", self.viewVariant)
self.controller.init() self.controller.init()
self.view.load() self.view.load()

View File

@ -40,8 +40,6 @@ method delete*(self: Module) =
self.controller.delete self.controller.delete
method load*(self: Module) = method load*(self: Module) =
singletonInstance.engine.setRootContextProperty("messagesModule", self.viewVariant)
self.controller.init() self.controller.init()
self.view.load() self.view.load()

View File

@ -76,5 +76,6 @@ method setActiveItemSubItem*(self: Controller, itemId: string, subItemId: string
self.delegate.activeItemSubItemSet(self.activeItemId, self.activeSubItemId) self.delegate.activeItemSubItemSet(self.activeItemId, self.activeSubItemId)
method getOneToOneChatNameAndImage*(self: Controller, chatId: string): tuple[name: string, image: string] = method getOneToOneChatNameAndImage*(self: Controller, chatId: string):
tuple[name: string, image: string, isIdenticon: bool] =
return self.chatService.getOneToOneChatNameAndImage(chatId) return self.chatService.getOneToOneChatNameAndImage(chatId)

View File

@ -38,6 +38,6 @@ method getChatDetailsForChatTypes*(self: AccessInterface, types: seq[ChatType]):
method setActiveItemSubItem*(self: AccessInterface, itemId: string, subItemId: string) {.base.} = method setActiveItemSubItem*(self: AccessInterface, itemId: string, subItemId: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getOneToOneChatNameAndImage*(self: AccessInterface, chatId: string): tuple[name: string, image: string] method getOneToOneChatNameAndImage*(self: AccessInterface, chatId: string):
{.base.} = tuple[name: string, image: string, isIdenticon: bool] {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -6,10 +6,11 @@ type
`type`: int `type`: int
subItems: SubModel subItems: SubModel
proc initItem*(id, name, icon, color, description: string, `type`: int, hasNotification: bool, notificationsCount: int, proc initItem*(id, name, icon: string, isIdenticon: bool, color, description: string, `type`: int, hasUnreadMessages: bool,
muted, active: bool, position: int): Item = notificationsCount: int, muted, active: bool, position: int): Item =
result = Item() result = Item()
result.setup(id, name, icon, color, description, hasNotification, notificationsCount, muted, active, position) result.setup(id, name, icon, isIdenticon, color, description, hasUnreadMessages, notificationsCount, muted, active,
position)
result.`type` = `type` result.`type` = `type`
result.subItems = newSubModel() result.subItems = newSubModel()
@ -25,13 +26,14 @@ proc type*(self: Item): int {.inline.} =
proc `$`*(self: Item): string = proc `$`*(self: Item): string =
result = fmt"""ChatSectionItem( result = fmt"""ChatSectionItem(
id: {self.id}, itemId: {self.id},
name: {self.name}, name: {self.name},
icon: {self.icon}, icon: {self.icon},
isIdenticon: {self.isIdenticon},
color: {self.color}, color: {self.color},
description: {self.description}, description: {self.description},
type: {self.`type`}, type: {self.`type`},
hasNotification: {self.hasNotification}, hasUnreadMessages: {self.hasUnreadMessages},
notificationsCount: {self.notificationsCount}, notificationsCount: {self.notificationsCount},
muted: {self.muted}, muted: {self.muted},
active: {self.active}, active: {self.active},

View File

@ -7,10 +7,11 @@ type
Id = UserRole + 1 Id = UserRole + 1
Name Name
Icon Icon
IsIdenticon
Color Color
Description Description
Type Type
HasNotification HasUnreadMessages
NotificationsCount NotificationsCount
Muted Muted
Active Active
@ -56,13 +57,14 @@ QtObject:
method roleNames(self: Model): Table[int, string] = method roleNames(self: Model): Table[int, string] =
{ {
ModelRole.Id.int:"id", ModelRole.Id.int:"itemId",
ModelRole.Name.int:"name", ModelRole.Name.int:"name",
ModelRole.Icon.int:"icon", ModelRole.Icon.int:"icon",
ModelRole.IsIdenticon.int:"isIdenticon",
ModelRole.Color.int:"color", ModelRole.Color.int:"color",
ModelRole.Description.int:"description", ModelRole.Description.int:"description",
ModelRole.Type.int:"type", ModelRole.Type.int:"type",
ModelRole.HasNotification.int:"hasNotification", ModelRole.HasUnreadMessages.int:"hasUnreadMessages",
ModelRole.NotificationsCount.int:"notificationsCount", ModelRole.NotificationsCount.int:"notificationsCount",
ModelRole.Muted.int:"muted", ModelRole.Muted.int:"muted",
ModelRole.Active.int:"active", ModelRole.Active.int:"active",
@ -87,14 +89,16 @@ QtObject:
result = newQVariant(item.name) result = newQVariant(item.name)
of ModelRole.Icon: of ModelRole.Icon:
result = newQVariant(item.icon) result = newQVariant(item.icon)
of ModelRole.IsIdenticon:
result = newQVariant(item.isIdenticon)
of ModelRole.Color: of ModelRole.Color:
result = newQVariant(item.color) result = newQVariant(item.color)
of ModelRole.Description: of ModelRole.Description:
result = newQVariant(item.description) result = newQVariant(item.description)
of ModelRole.Type: of ModelRole.Type:
result = newQVariant(item.`type`) result = newQVariant(item.`type`)
of ModelRole.HasNotification: of ModelRole.HasUnreadMessages:
result = newQVariant(item.hasNotification) result = newQVariant(item.hasUnreadMessages)
of ModelRole.NotificationsCount: of ModelRole.NotificationsCount:
result = newQVariant(item.notificationsCount) result = newQVariant(item.notificationsCount)
of ModelRole.Muted: of ModelRole.Muted:

View File

@ -73,10 +73,11 @@ proc buildChatUI(self: Module, events: EventEmitter, chatService: chat_service.S
let notificationsCount = c.unviewedMentionsCount let notificationsCount = c.unviewedMentionsCount
var chatName = c.name var chatName = c.name
var chatImage = c.identicon var chatImage = c.identicon
var isIdenticon = false
if(c.chatType == ChatType.OneToOne): if(c.chatType == ChatType.OneToOne):
(chatName, chatImage) = self.controller.getOneToOneChatNameAndImage(c.id) (chatName, chatImage, isIdenticon) = self.controller.getOneToOneChatNameAndImage(c.id)
let item = initItem(c.id, chatName, chatImage, c.color, c.description, c.chatType.int, hasNotification, let item = initItem(c.id, chatName, chatImage, isIdenticon, c.color, c.description, c.chatType.int, hasNotification,
notificationsCount, c.muted, false, 0) notificationsCount, c.muted, false, 0)
self.view.appendItem(item) self.view.appendItem(item)
self.addSubmodule(c.id, false, events, chatService, communityService, messageService) self.addSubmodule(c.id, false, events, chatService, communityService, messageService)
@ -93,6 +94,9 @@ proc buildCommunityUI(self: Module, events: EventEmitter, chatService: chat_serv
var selectedSubItemId = "" var selectedSubItemId = ""
let communityIds = self.controller.getCommunityIds() let communityIds = self.controller.getCommunityIds()
for cId in communityIds: for cId in communityIds:
if(self.controller.getMySectionId() != cId):
continue
# handle channels which don't belong to any category # handle channels which don't belong to any category
let chats = self.controller.getChats(cId, "") let chats = self.controller.getChats(cId, "")
for c in chats: for c in chats:
@ -100,7 +104,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter, chatService: chat_serv
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0 let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
let notificationsCount = chatDto.unviewedMentionsCount let notificationsCount = chatDto.unviewedMentionsCount
let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, chatDto.color, chatDto.description, let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color, chatDto.description,
chatDto.chatType.int, hasNotification, notificationsCount, chatDto.muted, false, c.position) chatDto.chatType.int, hasNotification, notificationsCount, chatDto.muted, false, c.position)
self.view.appendItem(channelItem) self.view.appendItem(channelItem)
self.addSubmodule(chatDto.id, true, events, chatService, communityService, messageService) self.addSubmodule(chatDto.id, true, events, chatService, communityService, messageService)
@ -126,8 +130,8 @@ proc buildCommunityUI(self: Module, events: EventEmitter, chatService: chat_serv
hasNotificationPerCategory = hasNotificationPerCategory or hasNotification hasNotificationPerCategory = hasNotificationPerCategory or hasNotification
notificationsCountPerCategory += notificationsCount notificationsCountPerCategory += notificationsCount
let channelItem = initSubItem(chatDto.id, chatDto.name, chatDto.identicon, chatDto.color, chatDto.description, let channelItem = initSubItem(chatDto.id, cat.id, chatDto.name, chatDto.identicon, false, chatDto.color,
hasNotification, notificationsCount, chatDto.muted, false, c.position) chatDto.description, hasNotification, notificationsCount, chatDto.muted, false, c.position)
categoryChannels.add(channelItem) categoryChannels.add(channelItem)
self.addSubmodule(chatDto.id, true, events, chatService, communityService, messageService) self.addSubmodule(chatDto.id, true, events, chatService, communityService, messageService)
@ -137,7 +141,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter, chatService: chat_serv
selectedItemId = cat.id selectedItemId = cat.id
selectedSubItemId = channelItem.id selectedSubItemId = channelItem.id
var categoryItem = initItem(cat.id, cat.name, "", "", "", ChatType.Unknown.int, hasNotificationPerCategory, var categoryItem = initItem(cat.id, cat.name, "", false, "", "", ChatType.Unknown.int, hasNotificationPerCategory,
notificationsCountPerCategory, false, false, cat.position) notificationsCountPerCategory, false, false, cat.position)
categoryItem.prependSubItems(categoryChannels) categoryItem.prependSubItems(categoryChannels)
self.view.appendItem(categoryItem) self.view.appendItem(categoryItem)

View File

@ -5,23 +5,31 @@ export base_item
type type
SubItem* = ref object of BaseItem SubItem* = ref object of BaseItem
parentId: string
proc initSubItem*(id, name, icon, color, description: string, hasNotification: bool, notificationsCount: int, proc initSubItem*(id, parentId, name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool,
muted, active: bool, position: int): SubItem = notificationsCount: int, muted, active: bool, position: int): SubItem =
result = SubItem() result = SubItem()
result.setup(id, name, icon, color, description, hasNotification, notificationsCount, muted, active, position) result.setup(id, name, icon, isIdenticon, color, description, hasUnreadMessages, notificationsCount, muted, active,
position)
result.parentId = parentId
proc delete*(self: SubItem) = proc delete*(self: SubItem) =
self.BaseItem.delete self.BaseItem.delete
proc parentId*(self: SubItem): string =
self.parentId
proc `$`*(self: SubItem): string = proc `$`*(self: SubItem): string =
result = fmt"""ChatSectionSubItem( result = fmt"""ChatSectionSubItem(
id: {self.id}, itemId: {self.id},
parentItemId: {self.parentId},
name: {self.name}, name: {self.name},
icon: {self.icon}, icon: {self.icon},
isIdenticon: {self.isIdenticon},
color: {self.color}, color: {self.color},
description: {self.description}, description: {self.description},
hasNotification: {self.hasNotification}, hasUnreadMessages: {self.hasUnreadMessages},
notificationsCount: {self.notificationsCount}, notificationsCount: {self.notificationsCount},
muted: {self.muted}, muted: {self.muted},
active: {self.active}, active: {self.active},

View File

@ -5,11 +5,13 @@ import sub_item
type type
ModelRole {.pure.} = enum ModelRole {.pure.} = enum
Id = UserRole + 1 Id = UserRole + 1
ParentId
Name Name
Icon Icon
IsIdenticon
Color Color
Description Description
HasNotification HasUnreadMessages
NotificationsCount NotificationsCount
Muted Muted
Active Active
@ -54,12 +56,14 @@ QtObject:
method roleNames(self: SubModel): Table[int, string] = method roleNames(self: SubModel): Table[int, string] =
{ {
ModelRole.Id.int:"id", ModelRole.Id.int:"itemId",
ModelRole.ParentId.int:"parentItemId",
ModelRole.Name.int:"name", ModelRole.Name.int:"name",
ModelRole.Icon.int:"icon", ModelRole.Icon.int:"icon",
ModelRole.IsIdenticon.int:"isIdenticon",
ModelRole.Color.int:"color", ModelRole.Color.int:"color",
ModelRole.Description.int:"description", ModelRole.Description.int:"description",
ModelRole.HasNotification.int:"hasNotification", ModelRole.HasUnreadMessages.int:"hasUnreadMessages",
ModelRole.NotificationsCount.int:"notificationsCount", ModelRole.NotificationsCount.int:"notificationsCount",
ModelRole.Muted.int:"muted", ModelRole.Muted.int:"muted",
ModelRole.Active.int:"active", ModelRole.Active.int:"active",
@ -79,16 +83,20 @@ QtObject:
case enumRole: case enumRole:
of ModelRole.Id: of ModelRole.Id:
result = newQVariant(item.id) result = newQVariant(item.id)
of ModelRole.ParentId:
result = newQVariant(item.parentId)
of ModelRole.Name: of ModelRole.Name:
result = newQVariant(item.name) result = newQVariant(item.name)
of ModelRole.Icon: of ModelRole.Icon:
result = newQVariant(item.icon) result = newQVariant(item.icon)
of ModelRole.IsIdenticon:
result = newQVariant(item.isIdenticon)
of ModelRole.Color: of ModelRole.Color:
result = newQVariant(item.color) result = newQVariant(item.color)
of ModelRole.Description: of ModelRole.Description:
result = newQVariant(item.description) result = newQVariant(item.description)
of ModelRole.HasNotification: of ModelRole.HasUnreadMessages:
result = newQVariant(item.hasNotification) result = newQVariant(item.hasUnreadMessages)
of ModelRole.NotificationsCount: of ModelRole.NotificationsCount:
result = newQVariant(item.notificationsCount) result = newQVariant(item.notificationsCount)
of ModelRole.Muted: of ModelRole.Muted:

View File

@ -53,7 +53,8 @@ method getChatById*(self: Service, chatId: string): ChatDto =
return self.chats[chatId] return self.chats[chatId]
method getOneToOneChatNameAndImage*(self: Service, chatId: string): tuple[name: string, image: string] = method getOneToOneChatNameAndImage*(self: Service, chatId: string):
tuple[name: string, image: string, isIdenticon: bool] =
return self.contactService.getContactNameAndImage(chatId) return self.contactService.getContactNameAndImage(chatId)
# TODO refactor this to new object types # TODO refactor this to new object types

View File

@ -23,8 +23,8 @@ method getChatsOfChatTypes*(self: ServiceInterface, types: seq[chat_dto.ChatType
method getChatById*(self: ServiceInterface, chatId: string): ChatDto {.base.} = method getChatById*(self: ServiceInterface, chatId: string): ChatDto {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getOneToOneChatNameAndImage*(self: ServiceInterface, chatId: string): tuple[name: string, image: string] method getOneToOneChatNameAndImage*(self: ServiceInterface, chatId: string):
{.base.} = tuple[name: string, image: string, isIdenticon: bool] {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method parseChatResponse*(self: ServiceInterface, response: string): (seq[Chat], seq[Message]) {.base.} = method parseChatResponse*(self: ServiceInterface, response: string): (seq[Chat], seq[Message]) {.base.} =

View File

@ -110,14 +110,16 @@ QtObject:
hasAddedUs: false hasAddedUs: false
) )
proc getContactNameAndImage*(self: Service, publicKey: string): tuple[name: string, image: string] = proc getContactNameAndImage*(self: Service, publicKey: string): tuple[name: string, image: string, isIdenticon: bool] =
## This proc should be used accross the app in order to have for the same contact ## This proc should be used accross the app in order to have for the same contact
## same image and name displayed everywhere in the app. ## same image and name displayed everywhere in the app.
let contactDto = self.getContactById(publicKey) let contactDto = self.getContactById(publicKey)
result.name = contactDto.userNameOrAlias() result.name = contactDto.userNameOrAlias()
result.image = contactDto.identicon result.image = contactDto.identicon
result.isIdenticon = contactDto.identicon.len > 0
if(contactDto.image.thumbnail.len > 0): if(contactDto.image.thumbnail.len > 0):
result.image = contactDto.image.thumbnail result.image = contactDto.image.thumbnail
result.isIdenticon = false
proc saveContact(self: Service, contact: ContactsDto) = proc saveContact(self: Service, contact: ContactsDto) =
# we must keep local contacts updated # we must keep local contacts updated

View File

@ -25,7 +25,10 @@ StatusAppThreePanelLayout {
handle: SplitViewHandle { implicitWidth: 5 } handle: SplitViewHandle { implicitWidth: 5 }
property var store // Important:
// Each `ChatLayout` has its own chatCommunitySectionModule
// (on the backend chat and community sections share the same module since they are actually the same)
property var chatCommunitySectionModule
// Not Refactored // Not Refactored
property var messageStore property var messageStore
@ -59,13 +62,13 @@ StatusAppThreePanelLayout {
leftPanel: Loader { leftPanel: Loader {
id: contactColumnLoader id: contactColumnLoader
sourceComponent: store.isCommunity()? communtiyColumnComponent : contactsColumnComponent sourceComponent: chatCommunitySectionModule.isCommunity()? communtiyColumnComponent : contactsColumnComponent
} }
centerPanel: ChatColumnView { centerPanel: ChatColumnView {
id: chatColumn id: chatColumn
rootStore: root.rootStore rootStore: root.rootStore
chatGroupsListViewCount: contactColumnLoader.item.chatGroupsListViewCount //chatGroupsListViewCount: contactColumnLoader.item.chatGroupsListViewCount
onOpenAppSearch: { onOpenAppSearch: {
root.openAppSearch() root.openAppSearch()
@ -74,38 +77,40 @@ StatusAppThreePanelLayout {
showRightPanel: (localAccountSensitiveSettings.expandUsersList && (localAccountSensitiveSettings.showOnlineUsers || chatsModel.communities.activeCommunity.active) showRightPanel: (localAccountSensitiveSettings.expandUsersList && (localAccountSensitiveSettings.showOnlineUsers || chatsModel.communities.activeCommunity.active)
&& (chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne)) && (chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne))
rightPanel: localAccountSensitiveSettings.communitiesEnabled && chatsModel.communities.activeCommunity.active ? communityUserListComponent : userListComponent rightPanel: localAccountSensitiveSettings.communitiesEnabled && chatCommunitySectionModule.isCommunity()? communityUserListComponent : userListComponent
Component { Component {
id: communityUserListComponent id: communityUserListComponent
CommunityUserListPanel { CommunityUserListPanel {
currentTime: chatColumn.currentTime //Not Refactored Yet
//currentTime: chatColumn.currentTime
messageContextMenu: quickActionMessageOptionsMenu messageContextMenu: quickActionMessageOptionsMenu
profilePubKey: userProfile.pubKey // profilePubKey: userProfile.pubKey
community: root.rootStore.chatsModelInst.communities.activeCommunity // community: root.rootStore.chatsModelInst.communities.activeCommunity
currentUserName: Utils.removeStatusEns(root.rootStore.profileModelInst.ens.preferredUsername // currentUserName: Utils.removeStatusEns(root.rootStore.profileModelInst.ens.preferredUsername
|| root.rootStore.profileModelInst.profile.username) // || root.rootStore.profileModelInst.profile.username)
currentUserOnline: root.rootStore.userProfileInst.userStatus // currentUserOnline: root.store.userProfileInst.userStatus
contactsList: root.rootStore.allContacts // contactsList: root.rootStore.allContacts
} }
} }
Component { Component {
id: userListComponent id: userListComponent
UserListPanel { UserListPanel {
currentTime: chatColumn.currentTime //Not Refactored Yet
userList: chatColumn.userList //currentTime: chatColumn.currentTime
//userList: chatColumn.userList
messageContextMenu: quickActionMessageOptionsMenu messageContextMenu: quickActionMessageOptionsMenu
profilePubKey: userProfile.pubKey // profilePubKey: userProfile.pubKey
contactsList: root.rootStore.allContacts // contactsList: root.rootStore.allContacts
isOnline: root.rootStore.chatsModelInst.isOnline // isOnline: root.rootStore.chatsModelInst.isOnline
} }
} }
Component { Component {
id: contactsColumnComponent id: contactsColumnComponent
ContactsColumnView { ContactsColumnView {
// Not Refactored chatSectionModule: root.chatCommunitySectionModule
store: root.rootStore store: root.rootStore
onOpenProfileClicked: { onOpenProfileClicked: {
root.profileButtonClicked(); root.profileButtonClicked();
@ -120,8 +125,9 @@ StatusAppThreePanelLayout {
Component { Component {
id: communtiyColumnComponent id: communtiyColumnComponent
CommunityColumnView { CommunityColumnView {
store: root.store communitySectionModule: root.chatCommunitySectionModule
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent store: root.rootStore
//pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
} }
} }
@ -130,7 +136,7 @@ StatusAppThreePanelLayout {
GroupInfoPopup { GroupInfoPopup {
// Not Refactored // Not Refactored
store: root.rootStore store: root.rootStore
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent //pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
} }
} }
@ -150,11 +156,12 @@ StatusAppThreePanelLayout {
//% "Are you sure you want to remove this contact?" //% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-") confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: { onConfirmButtonClicked: {
if (root.rootStore.contactsModuleInst.model.isAdded(chatColumn.contactToRemove)) { // Not Refactored Yet
root.rootStore.contactsModuleInst.model.removeContact(chatColumn.contactToRemove) // if (root.rootStore.contactsModuleInst.model.isAdded(chatColumn.contactToRemove)) {
} // root.rootStore.contactsModuleInst.model.removeContact(chatColumn.contactToRemove)
removeContactConfirmationDialog.parentPopup.close(); // }
removeContactConfirmationDialog.close(); // removeContactConfirmationDialog.parentPopup.close();
// removeContactConfirmationDialog.close();
} }
} }

View File

@ -26,7 +26,8 @@ Item {
anchors.fill: parent anchors.fill: parent
property var rootStore property var rootStore
property alias pinnedMessagesPopupComponent: pinnedMessagesPopupComponent property alias pinnedMessagesPopupComponent: pinnedMessagesPopupComponent
property int chatGroupsListViewCount: 0 // Not Refactored Yet
//property int chatGroupsListViewCount: 0
property bool isReply: false property bool isReply: false
property bool isImage: false property bool isImage: false
property bool isExtendedInput: isReply || isImage property bool isExtendedInput: isReply || isImage
@ -120,8 +121,9 @@ Item {
StackLayout { StackLayout {
anchors.fill: parent anchors.fill: parent
currentIndex: root.rootStore.chatsModelInst.channelView.activeChannelIndex > -1 // Not Refactored Yet
&& chatGroupsListViewCount > 0 ? 0 : 1 // currentIndex: root.rootStore.chatsModelInst.channelView.activeChannelIndex > -1
// && chatGroupsListViewCount > 0 ? 0 : 1
StatusImageModal { StatusImageModal {
id: imagePopup id: imagePopup

View File

@ -13,7 +13,8 @@ StatusPopupMenu {
id: root id: root
property var chatItem property var chatItem
property var store property var store
property bool communityActive: root.store.chatsModelInst.communities.activeCommunity.active // Not Refactored Yet
property bool communityActive: false // root.store.chatsModelInst.communities.activeCommunity.active
StatusMenuItem { StatusMenuItem {
id: viewProfileMenuItem id: viewProfileMenuItem

View File

@ -20,9 +20,15 @@ Item {
width: 304 width: 304
height: parent.height height: parent.height
// Important:
// We're here in case of CommunitySection
// This module is set from `ChatLayout` (each `ChatLayout` has its own communitySectionModule)
property var communitySectionModule
property var store property var store
// TODO unhardcode // TODO unhardcode
property int chatGroupsListViewCount: communityChatListAndCategories.chatList.count // Not Refactored Yet
//property int chatGroupsListViewCount: communityChatListAndCategories.chatList.count
property Component pinnedMessagesPopupComponent property Component pinnedMessagesPopupComponent
StatusChatInfoToolBar { StatusChatInfoToolBar {
@ -30,26 +36,27 @@ Item {
anchors.top: parent.top anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
chatInfoButton.title: root.store.chatsModelInst.communities.activeCommunity.name // Not Refactored Yet
chatInfoButton.subTitle: root.store.chatsModelInst.communities.activeCommunity.nbMembers === 1 ? // chatInfoButton.title: root.store.chatsModelInst.communities.activeCommunity.name
//% "1 Member" // chatInfoButton.subTitle: root.store.chatsModelInst.communities.activeCommunity.nbMembers === 1 ?
qsTrId("1-member") : // //% "1 Member"
//% "%1 Members" // qsTrId("1-member") :
qsTrId("-1-members").arg(root.store.chatsModelInst.communities.activeCommunity.nbMembers) // //% "%1 Members"
chatInfoButton.image.source: root.store.chatsModelInst.communities.activeCommunity.thumbnailImage // qsTrId("-1-members").arg(root.store.chatsModelInst.communities.activeCommunity.nbMembers)
chatInfoButton.icon.color: root.store.chatsModelInst.communities.activeCommunity.communityColor // chatInfoButton.image.source: root.store.chatsModelInst.communities.activeCommunity.thumbnailImage
menuButton.visible: root.store.chatsModelInst.communities.activeCommunity.admin && root.store.chatsModelInst.communities.activeCommunity.canManageUsers // chatInfoButton.icon.color: root.store.chatsModelInst.communities.activeCommunity.communityColor
chatInfoButton.onClicked: openPopup(communityProfilePopup, { // menuButton.visible: root.store.chatsModelInst.communities.activeCommunity.admin && root.store.chatsModelInst.communities.activeCommunity.canManageUsers
store: root.store, // chatInfoButton.onClicked: openPopup(communityProfilePopup, {
community: root.store.chatsModelInst.communities.activeCommunity // store: root.store,
}) // community: root.store.chatsModelInst.communities.activeCommunity
// })
popupMenu: StatusPopupMenu { popupMenu: StatusPopupMenu {
StatusMenuItem { StatusMenuItem {
//% "Create channel" //% "Create channel"
text: qsTrId("create-channel") text: qsTrId("create-channel")
icon.name: "channel" icon.name: "channel"
enabled: root.store.chatsModelInst.communities.activeCommunity.admin //enabled: root.store.chatsModelInst.communities.activeCommunity.admin
onTriggered: openPopup(createChannelPopup, {communityId: chatsModel.communities.activeCommunity.id}) onTriggered: openPopup(createChannelPopup, {communityId: chatsModel.communities.activeCommunity.id})
} }
@ -57,7 +64,7 @@ Item {
//% "Create category" //% "Create category"
text: qsTrId("create-category") text: qsTrId("create-category")
icon.name: "channel-category" icon.name: "channel-category"
enabled: root.store.chatsModelInst.communities.activeCommunity.admin //enabled: root.store.chatsModelInst.communities.activeCommunity.admin
onTriggered: openPopup(createCategoryPopup, {communityId: chatsModel.communities.activeCommunity.id}) onTriggered: openPopup(createCategoryPopup, {communityId: chatsModel.communities.activeCommunity.id})
} }
@ -67,7 +74,7 @@ Item {
//% "Invite people" //% "Invite people"
text: qsTrId("invite-people") text: qsTrId("invite-people")
icon.name: "share-ios" icon.name: "share-ios"
enabled: root.store.chatsModelInst.communities.activeCommunity.canManageUsers //enabled: root.store.chatsModelInst.communities.activeCommunity.canManageUsers
onTriggered: openPopup(inviteFriendsToCommunityPopup, { onTriggered: openPopup(inviteFriendsToCommunityPopup, {
community: root.store.chatsModelInst.communities.activeCommunity community: root.store.chatsModelInst.communities.activeCommunity
}) })
@ -77,13 +84,17 @@ Item {
Loader { Loader {
id: membershipRequests id: membershipRequests
property int nbRequests: root.store.chatsModelInst.communities.activeCommunity.communityMembershipRequests.nbRequests // Not Refactored Yet
property int nbRequests: 0
//property int nbRequests: root.store.chatsModelInst.communities.activeCommunity.communityMembershipRequests.nbRequests
anchors.top: communityHeader.bottom anchors.top: communityHeader.bottom
anchors.topMargin: active ? 8 : 0 anchors.topMargin: active ? 8 : 0
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
active: root.store.chatsModelInst.communities.activeCommunity.admin && nbRequests > 0 // Not Refactored Yet
active: nbRequests > 0
//active: root.store.chatsModelInst.communities.activeCommunity.admin && nbRequests > 0
height: nbRequests > 0 ? 64 : 0 height: nbRequests > 0 ? 64 : 0
sourceComponent: Component { sourceComponent: Component {
StatusContactRequestsIndicatorListItem { StatusContactRequestsIndicatorListItem {
@ -127,29 +138,36 @@ Item {
return implicitHeight return implicitHeight
} }
draggableItems: root.store.chatsModelInst.communities.activeCommunity.admin // draggableItems: root.store.chatsModelInst.communities.activeCommunity.admin
draggableCategories: root.store.chatsModelInst.communities.activeCommunity.admin // draggableCategories: root.store.chatsModelInst.communities.activeCommunity.admin
chatList.model: root.store.chatsModelInst.communities.activeCommunity.chats //chatList.model: root.store.chatsModelInst.communities.activeCommunity.chats
categoryList.model: root.store.chatsModelInst.communities.activeCommunity.categories //categoryList.model: root.store.chatsModelInst.communities.activeCommunity.categories
model: root.communitySectionModule.model
showCategoryActionButtons: root.store.chatsModelInst.communities.activeCommunity.admin onChatItemSelected: {
showPopupMenu: root.store.chatsModelInst.communities.activeCommunity.admin && chatsModel.communities.activeCommunity.canManageUsers if(categoryId === "")
selectedChatId: root.store.chatsModelInst.channelView.activeChannel.id root.communitySectionModule.setActiveItem(id, "")
else
onChatItemSelected: root.store.chatsModelInst.channelView.setActiveChannel(id) root.communitySectionModule.setActiveItem(categoryId, id)
onChatItemUnmuted: root.store.chatsModelInst.channelView.unmuteChatItem(id)
onChatItemReordered: function (categoryId, id, from, to) {
root.store.chatsModelInst.communities.reorderCommunityChannel(chatsModel.communities.activeCommunity.id, categoryId, id, to);
}
onChatListCategoryReordered: function (categoryId, from, to) {
root.store.chatsModelInst.communities.reorderCommunityCategories(chatsModel.communities.activeCommunity.id, categoryId, to);
} }
onCategoryAddButtonClicked: openPopup(createChannelPopup, { // showCategoryActionButtons: root.store.chatsModelInst.communities.activeCommunity.admin
communityId: root.store.chatsModelInst.communities.activeCommunity.id, // showPopupMenu: root.store.chatsModelInst.communities.activeCommunity.admin && chatsModel.communities.activeCommunity.canManageUsers
categoryId: id //selectedChatId: root.store.chatsModelInst.channelView.activeChannel.id
})
// onChatItemSelected: root.store.chatsModelInst.channelView.setActiveChannel(id)
// onChatItemUnmuted: root.store.chatsModelInst.channelView.unmuteChatItem(id)
// onChatItemReordered: function (categoryId, id, from, to) {
// root.store.chatsModelInst.communities.reorderCommunityChannel(chatsModel.communities.activeCommunity.id, categoryId, id, to);
// }
// onChatListCategoryReordered: function (categoryId, from, to) {
// root.store.chatsModelInst.communities.reorderCommunityCategories(chatsModel.communities.activeCommunity.id, categoryId, to);
// }
// onCategoryAddButtonClicked: openPopup(createChannelPopup, {
// communityId: root.store.chatsModelInst.communities.activeCommunity.id,
// categoryId: id
// })
popupMenu: StatusPopupMenu { popupMenu: StatusPopupMenu {
StatusMenuItem { StatusMenuItem {
@ -164,7 +182,9 @@ Item {
//% "Create category" //% "Create category"
text: qsTrId("create-category") text: qsTrId("create-category")
icon.name: "channel-category" icon.name: "channel-category"
enabled: root.store.chatsModelInst.communities.activeCommunity.admin // Not Refactored Yet
enabled: false
//enabled: root.store.chatsModelInst.communities.activeCommunity.admin
onTriggered: openPopup(createCategoryPopup, {communityId: root.store.chatsModelInst.communities.activeCommunity.id}) onTriggered: openPopup(createCategoryPopup, {communityId: root.store.chatsModelInst.communities.activeCommunity.id})
} }
@ -174,7 +194,9 @@ Item {
//% "Invite people" //% "Invite people"
text: qsTrId("invite-people") text: qsTrId("invite-people")
icon.name: "share-ios" icon.name: "share-ios"
enabled: root.store.chatsModelInst.communities.activeCommunity.canManageUsers // Not Refactored Yet
enabled: false
//enabled: root.store.chatsModelInst.communities.activeCommunity.canManageUsers
onTriggered: openPopup(inviteFriendsToCommunityPopup, { onTriggered: openPopup(inviteFriendsToCommunityPopup, {
community: root.store.chatsModelInst.communities.activeCommunity community: root.store.chatsModelInst.communities.activeCommunity
}) })
@ -190,7 +212,9 @@ Item {
} }
StatusMenuItem { StatusMenuItem {
enabled: root.store.chatsModelInst.communities.activeCommunity.admin // Not Refactored Yet
enabled: true
//enabled: root.store.chatsModelInst.communities.activeCommunity.admin
//% "Edit Category" //% "Edit Category"
text: qsTrId("edit-category") text: qsTrId("edit-category")
icon.name: "edit" icon.name: "edit"
@ -205,11 +229,15 @@ Item {
} }
StatusMenuSeparator { StatusMenuSeparator {
visible: root.store.chatsModelInst.communities.activeCommunity.admin // Not Refactored Yet
visible: true
//visible: root.store.chatsModelInst.communities.activeCommunity.admin
} }
StatusMenuItem { StatusMenuItem {
enabled: root.store.chatsModelInst.communities.activeCommunity.admin // Not Refactored Yet
enabled: true
//enabled: root.store.chatsModelInst.communities.activeCommunity.admin
//% "Delete Category" //% "Delete Category"
text: qsTrId("delete-category") text: qsTrId("delete-category")
icon.name: "delete" icon.name: "delete"
@ -373,9 +401,3 @@ Item {
} }
} }
} }
/*##^##
Designer {
D{i:0;autoSize:true;formeditorColor:"#ffffff";height:480;width:640}
}
##^##*/

View File

@ -21,8 +21,14 @@ Item {
width: 304 width: 304
height: parent.height height: parent.height
// Important:
// We're here in case of ChatSection
// This module is set from `ChatLayout` (each `ChatLayout` has its own chatSectionModule)
property var chatSectionModule
property var store property var store
property int chatGroupsListViewCount: channelList.chatListItems.count // Not Refactored Yet
//property int chatGroupsListViewCount: channelList.model.count
signal openProfileClicked() signal openProfileClicked()
signal openAppSearch() signal openAppSearch()
@ -223,41 +229,35 @@ Item {
StatusChatList { StatusChatList {
id: channelList id: channelList
chatNameFn: function (chatItem) {
return chatItem.chatType !== Constants.chatTypePublic ?
Emoji.parse(Utils.removeStatusEns(Utils.filterXSS(chatItem.name))) :
Utils.filterXSS(chatItem.name)
}
profileImageFn: function (id) {
return appMain.getProfileImage(id)
}
Connections { Connections {
target: root.store.allContacts target: root.store.allContacts
onContactChanged: { onContactChanged: {
for (var i = 0; i < channelList.chatListItems.count; i++) { // Not Refactored Yet
if (!!channelList.statusChatListItems) { // for (var i = 0; i < channelList.chatListItems.count; i++) {
let chatItem = !!channelList.statusChatListItems.model.items ? // if (!!channelList.statusChatListItems) {
channelList.statusChatListItems.model.items.get(i) : null // let chatItem = !!channelList.statusChatListItems.model.items ?
if (chatItem && chatItem.chatId === pubkey) { // channelList.statusChatListItems.model.items.get(i) : null
let profileImage = appMain.getProfileImage(pubkey) // if (chatItem && chatItem.chatId === pubkey) {
if (!!profileImage) { // let profileImage = appMain.getProfileImage(pubkey)
chatItem.image.isIdenticon = false // if (!!profileImage) {
chatItem.image.source = profileImage // chatItem.image.isIdenticon = false
} // chatItem.image.source = profileImage
break; // }
} // break;
} // }
} // }
// }
} }
} }
chatListItems.model: root.store.chatsModelInst.channelView.chats model: root.chatSectionModule.model
selectedChatId: root.store.chatsModelInst.channelView.activeChannel.id onChatItemSelected: root.chatSectionModule.setActiveItem(id, "")
onChatItemSelected: root.store.chatsModelInst.channelView.setActiveChannel(id) // chatListItems.model: root.store.chatsModelInst.channelView.chats
onChatItemUnmuted: root.store.chatsModelInst.channelView.unmuteChatItem(id) // selectedChatId: root.store.chatsModelInst.channelView.activeChannel.id
// onChatItemSelected: root.store.chatsModelInst.channelView.setActiveChannel(id)
// onChatItemUnmuted: root.store.chatsModelInst.channelView.unmuteChatItem(id)
popupMenu: ChatContextMenuView { popupMenu: ChatContextMenuView {
id: chatContextMenuView id: chatContextMenuView

View File

@ -360,7 +360,7 @@ Item {
for(let i = this.children.length - 1; i >=0; i--) for(let i = this.children.length - 1; i >=0; i--)
{ {
var obj = this.children[i]; var obj = this.children[i];
if(obj && obj.sectionId == mainModule.activeSection.id) if(obj && obj.sectionId && obj.sectionId == mainModule.activeSection.id)
{ {
return i return i
} }
@ -407,7 +407,9 @@ Item {
browserLayoutContainer.active = true; browserLayoutContainer.active = true;
} }
timelineLayoutContainer.active = obj === timelineLayoutContainer if(obj === timelineLayoutContainer){
timelineLayoutContainer.active = true
}
if(obj === walletLayoutContainer){ if(obj === walletLayoutContainer){
walletLayoutContainer.showSigningPhrasePopup(); walletLayoutContainer.showSigningPhrasePopup();
@ -436,7 +438,7 @@ Item {
} }
Component.onCompleted: { Component.onCompleted: {
store = mainModule.getChatSectionModule() chatCommunitySectionModule = mainModule.getChatSectionModule()
} }
} }
@ -532,7 +534,7 @@ Item {
// we cannot return QVariant if we pass another parameter in a function call // we cannot return QVariant if we pass another parameter in a function call
// that's why we're using it this way // that's why we're using it this way
mainModule.prepareCommunitySectionModuleForCommunityId(model.id) mainModule.prepareCommunitySectionModuleForCommunityId(model.id)
store = mainModule.getCommunitySectionModule() chatCommunitySectionModule = mainModule.getCommunitySectionModule()
} }
} }
} }
@ -540,6 +542,73 @@ Item {
} }
} }
// This doesn't exists, not sure how this part ended up here?!?!
// We need to figure out what happened and fix this.
// So far just want to discard this, but leave it in order to check it later.
// Connections {
// target: profileModel
// onSettingsFileChanged: {
// // Since https://github.com/status-im/status-desktop/commit/93668ff75
// // we're hiding the setting to change appearance for compact normal mode
// // of the UI. For now, compact mode is the new default.
// //
// // Prior to this change, most likely many users are still using the
// // normal mode configuration, so we have to enforce compact mode for
// // those.
// if (!localAccountSensitiveSettings.useCompactMode) {
// localAccountSensitiveSettings.useCompactMode = true
// }
// const whitelist = profileModel.getLinkPreviewWhitelist()
// try {
// const whiteListedSites = JSON.parse(whitelist)
// let settingsUpdated = false
// // Add Status links to whitelist
// whiteListedSites.push({title: "Status", address: Constants.deepLinkPrefix, imageSite: false})
// whiteListedSites.push({title: "Status", address: Constants.joinStatusLink, imageSite: false})
// let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites
// if (!settings) {
// settings = {}
// }
// // Set Status links as true. We intercept thoseURLs so it is privacy-safe
// if (!settings[Constants.deepLinkPrefix] || !settings[Constants.joinStatusLink]) {
// settings[Constants.deepLinkPrefix] = true
// settings[Constants.joinStatusLink] = true
// settingsUpdated = true
// }
// const whitelistedHostnames = []
// // Add whitelisted sites in to app settings that are not already there
// whiteListedSites.forEach(site => {
// if (!settings.hasOwnProperty(site.address)) {
// settings[site.address] = false
// settingsUpdated = true
// }
// whitelistedHostnames.push(site.address)
// })
// // Remove any whitelisted sites from app settings that don't exist in the
// // whitelist from status-go
// Object.keys(settings).forEach(settingsHostname => {
// if (!whitelistedHostnames.includes(settingsHostname)) {
// delete settings[settingsHostname]
// settingsUpdated = true
// }
// })
// if (settingsUpdated) {
// localAccountSensitiveSettings.whitelistedUnfurlingSites = settings
// }
// } catch (e) {
// console.error('Could not parse the whitelist for sites', e)
// }
// appMain.settingsLoaded()
// }
// }
Connections { Connections {
target: chatsModel target: chatsModel
onNotificationClicked: { onNotificationClicked: {