fix: fix channel color in communities

This commit is contained in:
Jonathan Rainville 2021-03-02 15:43:32 -05:00 committed by Iuri Matias
parent b33a7b8fcf
commit 84034d5dbf
8 changed files with 39 additions and 15 deletions

View File

@ -91,6 +91,25 @@ QtObject:
result.setup()
proc getChannel*(self: ChatsView, index: int): Chat =
if (self.communities.activeCommunity.active):
return self.communities.activeCommunity.chats.getChannel(index)
else:
return self.chats.getChannel(index)
proc getChannelById*(self: ChatsView, channel: string): Chat =
if (self.communities.activeCommunity.active):
return self.communities.activeCommunity.chats.getChannel(self.communities.activeCommunity.chats.chats.findIndexById(channel))
else:
return self.chats.getChannel(self.chats.chats.findIndexById(channel))
proc updateChannelInRightList*(self: ChatsView, channel: Chat) =
if (self.communities.activeCommunity.active):
self.communities.activeCommunity.chats.updateChat(channel)
else:
self.chats.updateChat(channel)
proc oldestMessageTimestampChanged*(self: ChatsView) {.signal.}
proc getOldestMessageTimestamp*(self: ChatsView): QVariant {.slot.} =
@ -125,7 +144,10 @@ QtObject:
read = getCommunities
proc getChannelColor*(self: ChatsView, channel: string): string {.slot.} =
self.chats.getChannelColor(channel)
if (channel == ""): return
let selectedChannel = self.getChannelById(channel)
if (selectedChannel.id == "") : return
return selectedChannel.color
proc replaceMentionsWithPubKeys(self: ChatsView, mentions: seq[string], contacts: seq[Profile], message: string, predicate: proc (contact: Profile): string): string =
var updatedMessage = message
@ -168,18 +190,6 @@ QtObject:
channelId = "@" & self.pubKey
self.status.chat.sendMessage(channelId, m, replyTo, contentType)
proc getChannel*(self: ChatsView, index: int): Chat =
if (self.communities.activeCommunity.active):
return self.communities.activeCommunity.chats.getChannel(index)
else:
return self.chats.getChannel(index)
proc getChannelById*(self: ChatsView, channel: string): Chat =
if (self.communities.activeCommunity.active):
return self.communities.activeCommunity.chats.getChannel(self.communities.activeCommunity.chats.chats.findIndexById(channel))
else:
return self.chats.getChannel(self.chats.chats.findIndexById(channel))
proc verifyMessageSent*(self: ChatsView, data: string) {.slot.} =
let messageData = data.parseJson

View File

@ -27,7 +27,14 @@ Column {
if (chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne) {
return Style.current.transparent
}
return chatsModel.activeChannel.color
if (chatsModel.activeChannel.color) {
return chatsModel.activeChannel.color
}
const color = chatsModel.getChannelColor(chatId)
if (!color) {
return Style.current.orange
}
return color
}
RoundedImage {

View File

@ -60,6 +60,7 @@ Rectangle {
id: chatInfo
StatusChatInfo {
identiconSize: 36
chatId: chatsModel.activeChannel.id
chatName: chatsModel.activeChannel.name
chatType: chatsModel.activeChannel.chatType
identicon: chatsModel.activeChannel.identicon

View File

@ -56,6 +56,7 @@ Rectangle {
id: contactImage
height: !isCompact ? 40 : 28
width: !isCompact ? 40 : 28
chatId: wrapper.chatId
chatName: wrapper.name
chatType: wrapper.chatType
identicon: wrapper.profileImage || wrapper.identicon

View File

@ -61,6 +61,7 @@ ModalPopup {
height: 36
anchors.top: parent.top
color: popup.channel.color
chatId: popup.channel.id
chatName: popup.channel.name
}

View File

@ -34,6 +34,7 @@ Item {
StatusIdenticon {
id: chatIdenticon
chatType: root.chatType
chatId: root.chatId
chatName: root.chatName
identicon: root.profileImage || root.identicon
width: root.isCompact ? 20 : root.identiconSize

View File

@ -6,6 +6,7 @@ import "../../shared/status"
Item {
id: root
property string chatId
property string chatName
property int chatType
property string identicon
@ -22,6 +23,7 @@ Item {
id: letterIdenticon
StatusLetterIdenticon {
chatId: root.chatId
chatName: root.chatName
width: parent.width
height: parent.height

View File

@ -5,6 +5,7 @@ import "../../shared"
Rectangle {
id: root
property string chatId
property string chatName
width: 40
@ -12,7 +13,7 @@ Rectangle {
radius: width / 2
color: {
const color = chatsModel.getChannelColor(root.chatName.startsWith("#") ? root.chatName.substr(1) : root.chatName)
const color = chatsModel.getChannelColor(chatId)
if (!color) {
return Style.current.orange
}