mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-22 19:48:52 +00:00
Various fixes
- Make the topbar channel identifier color match the channel list color - Display private groups on the channel list - Reduce chat identifier height
This commit is contained in:
parent
7295fde809
commit
afc247be23
@ -41,10 +41,10 @@ proc handleChatEvents(self: ChatController) =
|
|||||||
self.view.pushMessage(chatMessage)
|
self.view.pushMessage(chatMessage)
|
||||||
|
|
||||||
self.status.events.on("channelJoined") do(e: Args):
|
self.status.events.on("channelJoined") do(e: Args):
|
||||||
var channelMessage = ChannelArgs(e)
|
var channel = ChannelArgs(e)
|
||||||
let chatItem = newChatItem(id = channelMessage.channel, channelMessage.chatTypeInt)
|
let chatItem = newChatItem(id = channel.channel, name = channel.name, chatType = channel.chatTypeInt)
|
||||||
discard self.view.chats.addChatItemToList(chatItem)
|
discard self.view.chats.addChatItemToList(chatItem)
|
||||||
self.status.chat.chatMessages(channelMessage.channel)
|
self.status.chat.chatMessages(channel.channel)
|
||||||
|
|
||||||
self.status.events.on("channelLeft") do(e: Args):
|
self.status.events.on("channelLeft") do(e: Args):
|
||||||
discard self.view.chats.removeChatItemFromList(self.view.activeChannel.chatItem.id)
|
discard self.view.chats.removeChatItemFromList(self.view.activeChannel.chatItem.id)
|
||||||
|
@ -12,6 +12,7 @@ type
|
|||||||
UnreadMessages = UserRole + 4
|
UnreadMessages = UserRole + 4
|
||||||
Identicon = UserRole + 5
|
Identicon = UserRole + 5
|
||||||
ChatType = UserRole + 6
|
ChatType = UserRole + 6
|
||||||
|
Color = UserRole + 7
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
@ -44,6 +45,7 @@ QtObject:
|
|||||||
of ChannelsRoles.UnreadMessages: result = newQVariant(chatItem.unviewedMessagesCount)
|
of ChannelsRoles.UnreadMessages: result = newQVariant(chatItem.unviewedMessagesCount)
|
||||||
of ChannelsRoles.Identicon: result = newQVariant(chatItem.identicon)
|
of ChannelsRoles.Identicon: result = newQVariant(chatItem.identicon)
|
||||||
of ChannelsRoles.ChatType: result = newQVariant(chatItem.chatType.int)
|
of ChannelsRoles.ChatType: result = newQVariant(chatItem.chatType.int)
|
||||||
|
of ChannelsRoles.Color: result = newQVariant(chatItem.color)
|
||||||
|
|
||||||
method roleNames(self: ChannelsList): Table[int, string] =
|
method roleNames(self: ChannelsList): Table[int, string] =
|
||||||
{
|
{
|
||||||
@ -52,7 +54,8 @@ QtObject:
|
|||||||
ChannelsRoles.LastMessage.int: "lastMessage",
|
ChannelsRoles.LastMessage.int: "lastMessage",
|
||||||
ChannelsRoles.UnreadMessages.int: "unviewedMessagesCount",
|
ChannelsRoles.UnreadMessages.int: "unviewedMessagesCount",
|
||||||
ChannelsRoles.Identicon.int: "identicon",
|
ChannelsRoles.Identicon.int: "identicon",
|
||||||
ChannelsRoles.ChatType.int: "chatType"
|
ChannelsRoles.ChatType.int: "chatType",
|
||||||
|
ChannelsRoles.Color.int: "color"
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
proc addChatItemToList*(self: ChannelsList, channel: ChatItem): int =
|
proc addChatItemToList*(self: ChannelsList, channel: ChatItem): int =
|
||||||
@ -62,7 +65,7 @@ QtObject:
|
|||||||
self.beginInsertRows(newQModelIndex(), 0, 0)
|
self.beginInsertRows(newQModelIndex(), 0, 0)
|
||||||
self.chats.insert(channel, 0)
|
self.chats.insert(channel, 0)
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
result = self.chats.len - 1
|
result = 0
|
||||||
|
|
||||||
proc removeChatItemFromList*(self: ChannelsList, channel: string): int =
|
proc removeChatItemFromList*(self: ChannelsList, channel: string): int =
|
||||||
let idx = self.chats.findById(channel)
|
let idx = self.chats.findById(channel)
|
||||||
@ -90,20 +93,20 @@ QtObject:
|
|||||||
proc updateChat*(self: ChannelsList, channel: ChatItem) =
|
proc updateChat*(self: ChannelsList, channel: ChatItem) =
|
||||||
let idx = self.upsertChannel(channel)
|
let idx = self.upsertChannel(channel)
|
||||||
let topLeft = self.createIndex(0, 0, nil)
|
let topLeft = self.createIndex(0, 0, nil)
|
||||||
let bottomRight = self.createIndex(self.chats.len - 1, 0, nil)
|
let bottomRight = self.createIndex(self.chats.len, 0, nil)
|
||||||
if(idx != 0): # Move last updated chat to the top of the list
|
if idx != 0: # Move last updated chat to the top of the list
|
||||||
self.chats.del(idx)
|
self.chats.delete(idx)
|
||||||
self.chats.insert(channel, 0)
|
self.chats.insert(channel, 0)
|
||||||
else:
|
else:
|
||||||
self.chats[0] = channel
|
self.chats[0] = channel
|
||||||
|
|
||||||
self.dataChanged(topLeft, bottomRight, @[ChannelsRoles.Name.int, ChannelsRoles.LastMessage.int, ChannelsRoles.Timestamp.int, ChannelsRoles.LastMessage.int, ChannelsRoles.UnreadMessages.int, ChannelsRoles.Identicon.int, ChannelsRoles.LastMessage.int])
|
self.dataChanged(topLeft, bottomRight, @[ChannelsRoles.Name.int, ChannelsRoles.LastMessage.int, ChannelsRoles.Timestamp.int, ChannelsRoles.UnreadMessages.int, ChannelsRoles.Identicon.int, ChannelsRoles.ChatType.int, ChannelsRoles.Color.int])
|
||||||
|
|
||||||
proc clearUnreadMessagesCount*(self: ChannelsList, channel: ChatItem) =
|
proc clearUnreadMessagesCount*(self: ChannelsList, channel: ChatItem) =
|
||||||
let idx = self.chats.findById(channel.id)
|
let idx = self.chats.findById(channel.id)
|
||||||
let topLeft = self.createIndex(0, 0, nil)
|
let topLeft = self.createIndex(0, 0, nil)
|
||||||
let bottomRight = self.createIndex(self.chats.len - 1, 0, nil)
|
let bottomRight = self.createIndex(self.chats.len, 0, nil)
|
||||||
channel.unviewedMessagesCount = 0
|
channel.unviewedMessagesCount = 0
|
||||||
self.chats[idx] = channel
|
self.chats[idx] = channel
|
||||||
|
|
||||||
self.dataChanged(topLeft, bottomRight, @[ChannelsRoles.Name.int, ChannelsRoles.LastMessage.int, ChannelsRoles.Timestamp.int, ChannelsRoles.LastMessage.int, ChannelsRoles.UnreadMessages.int, ChannelsRoles.Identicon.int, ChannelsRoles.LastMessage.int])
|
self.dataChanged(topLeft, bottomRight, @[ChannelsRoles.Name.int, ChannelsRoles.LastMessage.int, ChannelsRoles.Timestamp.int, ChannelsRoles.UnreadMessages.int, ChannelsRoles.Identicon.int, ChannelsRoles.ChatType.int, ChannelsRoles.Color.int])
|
||||||
|
@ -18,6 +18,7 @@ type
|
|||||||
|
|
||||||
ChannelArgs* = ref object of Args
|
ChannelArgs* = ref object of Args
|
||||||
channel*: string
|
channel*: string
|
||||||
|
name*: string
|
||||||
chatTypeInt*: ChatType
|
chatTypeInt*: ChatType
|
||||||
|
|
||||||
ChatArgs* = ref object of Args
|
ChatArgs* = ref object of Args
|
||||||
@ -69,7 +70,7 @@ proc join*(self: ChatModel, chatId: string, chatType: ChatType) =
|
|||||||
else:
|
else:
|
||||||
self.events.emit("mailserverTopics", TopicArgs(topics: topics));
|
self.events.emit("mailserverTopics", TopicArgs(topics: topics));
|
||||||
|
|
||||||
self.events.emit("channelJoined", ChannelArgs(channel: chatId, chatTypeInt: chatType))
|
self.events.emit("channelJoined", ChannelArgs(channel: chatId, chatTypeInt: chatType, name: chatId))
|
||||||
self.events.emit("activeChannelChanged", ChannelArgs(channel: self.getActiveChannel()))
|
self.events.emit("activeChannelChanged", ChannelArgs(channel: self.getActiveChannel()))
|
||||||
|
|
||||||
proc init*(self: ChatModel) =
|
proc init*(self: ChatModel) =
|
||||||
@ -80,7 +81,7 @@ proc init*(self: ChatModel) =
|
|||||||
if self.hasChannel(chat.id): continue
|
if self.hasChannel(chat.id): continue
|
||||||
filters.add status_chat.buildFilter(chatId = chat.id, oneToOne = chat.chatType.isOneToOne)
|
filters.add status_chat.buildFilter(chatId = chat.id, oneToOne = chat.chatType.isOneToOne)
|
||||||
self.channels.incl chat.id
|
self.channels.incl chat.id
|
||||||
self.events.emit("channelJoined", ChannelArgs(channel: chat.id, chatTypeInt: chat.chatType))
|
self.events.emit("channelJoined", ChannelArgs(channel: chat.id, chatTypeInt: chat.chatType, name: chat.name))
|
||||||
|
|
||||||
if filters.len == 0: return
|
if filters.len == 0: return
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@ type ChatItem* = ref object
|
|||||||
color*: string
|
color*: string
|
||||||
identicon*: string
|
identicon*: string
|
||||||
|
|
||||||
proc newChatItem*(id: string, chatType: ChatType, lastMessage: string = "", timestamp: int64 = 0, unviewedMessagesCount: int = 0, color: string = "", identicon: string = ""): ChatItem =
|
proc newChatItem*(id: string, name: string, chatType: ChatType, lastMessage: string = "", timestamp: int64 = 0, unviewedMessagesCount: int = 0, color: string = "", identicon: string = ""): ChatItem =
|
||||||
new(result)
|
new(result)
|
||||||
result.id = id
|
result.id = id
|
||||||
result.name = case chatType
|
result.name = case chatType
|
||||||
of ChatType.Public: id
|
of ChatType.Public: name
|
||||||
of ChatType.OneToOne: generateAlias(id)
|
of ChatType.OneToOne: generateAlias(id)
|
||||||
of ChatType.PrivateGroupChat: "TODO: Private Group Name"
|
of ChatType.PrivateGroupChat: name
|
||||||
of ChatType.Unknown: "Unknown: " & id
|
of ChatType.Unknown: "Unknown: " & id
|
||||||
result.chatType = chatType
|
result.chatType = chatType
|
||||||
result.lastMessage = lastMessage
|
result.lastMessage = lastMessage
|
||||||
@ -42,7 +42,7 @@ proc chatName(chat: Chat): string =
|
|||||||
case chat.chatType
|
case chat.chatType
|
||||||
of ChatType.OneToOne: result = chat.lastMessage.alias
|
of ChatType.OneToOne: result = chat.lastMessage.alias
|
||||||
of ChatType.Public: result = chat.name
|
of ChatType.Public: result = chat.name
|
||||||
of ChatType.PrivateGroupChat: result = "TODO: determine private group name"
|
of ChatType.PrivateGroupChat: result = chat.name
|
||||||
of ChatType.Unknown: result = "Unknown"
|
of ChatType.Unknown: result = "Unknown"
|
||||||
|
|
||||||
proc toChatItem*(chat: Chat): ChatItem =
|
proc toChatItem*(chat: Chat): ChatItem =
|
||||||
|
@ -24,7 +24,7 @@ Item {
|
|||||||
height: {
|
height: {
|
||||||
switch(contentType){
|
switch(contentType){
|
||||||
case Constants.chatIdentifier:
|
case Constants.chatIdentifier:
|
||||||
return parent.parent.height
|
return parent.parent.height - 100
|
||||||
case Constants.stickerType:
|
case Constants.stickerType:
|
||||||
return stickerId.height + 50
|
return stickerId.height + 50
|
||||||
default:
|
default:
|
||||||
@ -70,13 +70,7 @@ Item {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
visible: chatsModel.activeChannel.chatType != Constants.chatTypeOneToOne
|
visible: chatsModel.activeChannel.chatType != Constants.chatTypeOneToOne
|
||||||
text: {
|
text: (chatsModel.activeChannel.name.charAt(0) == "#" ? chatsModel.activeChannel.name.charAt(1) : chatsModel.activeChannel.name.charAt(0)).toUpperCase()
|
||||||
if (chatsModel.activeChannel.chatType == Constants.chatTypeOneToOne) {
|
|
||||||
return chatsModel.activeChannel.name;
|
|
||||||
} else {
|
|
||||||
return (chatId.charAt(0) == "#" ? chatId.charAt(1) : chatId.charAt(0)).toUpperCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
font.pixelSize: 51
|
font.pixelSize: 51
|
||||||
@ -89,10 +83,10 @@ Item {
|
|||||||
Text {
|
Text {
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
text: {
|
text: {
|
||||||
if (chatsModel.activeChannel.chatType == Constants.chatTypeOneToOne) {
|
if (chatsModel.activeChannel.chatType != Constants.chatTypePublic) {
|
||||||
return chatsModel.activeChannel.name;
|
return chatsModel.activeChannel.name;
|
||||||
} else {
|
} else {
|
||||||
return "#" + chatId;
|
return "#" + chatsModel.activeChannel.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
|
@ -29,7 +29,7 @@ Rectangle {
|
|||||||
id: channelName
|
id: channelName
|
||||||
width: 80
|
width: 80
|
||||||
height: 20
|
height: 20
|
||||||
text: chatsModel.activeChannel.chatType == Constants.chatTypeOneToOne ? chatsModel.activeChannel.name : channelNameStr
|
text: chatsModel.activeChannel.chatType != Constants.chatTypePublic ? chatsModel.activeChannel.name : channelNameStr
|
||||||
anchors.left: channelIcon.right
|
anchors.left: channelIcon.right
|
||||||
anchors.leftMargin: Theme.smallPadding
|
anchors.leftMargin: Theme.smallPadding
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
@ -44,7 +44,13 @@ Rectangle {
|
|||||||
id: channelIdentifier
|
id: channelIdentifier
|
||||||
color: Theme.darkGrey
|
color: Theme.darkGrey
|
||||||
// TODO change this in case of private message
|
// TODO change this in case of private message
|
||||||
text: "Public chat"
|
text: {
|
||||||
|
switch(chatsModel.activeChannel.chatType){
|
||||||
|
case Constants.chatTypePublic: return qsTr("Public chat")
|
||||||
|
case Constants.chatTypeOneToOne: return qsTr("TODO: Contact/Not a contact")
|
||||||
|
case Constants.chatTypePrivateGroupChat: return qsTr("TODO: N members")
|
||||||
|
}
|
||||||
|
}
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
anchors.left: channelIcon.right
|
anchors.left: channelIcon.right
|
||||||
anchors.leftMargin: Theme.smallPadding
|
anchors.leftMargin: Theme.smallPadding
|
||||||
|
@ -43,7 +43,7 @@ Rectangle {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: contactInfo
|
id: contactInfo
|
||||||
text: chatType == Constants.chatTypeOneToOne ? name : "#" + name
|
text: chatType != Constants.chatTypePublic ? name : "#" + name
|
||||||
anchors.right: contactTime.left
|
anchors.right: contactTime.left
|
||||||
anchors.rightMargin: Theme.smallPadding
|
anchors.rightMargin: Theme.smallPadding
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
@ -55,6 +55,7 @@ Rectangle {
|
|||||||
anchors.topMargin: Theme.smallPadding
|
anchors.topMargin: Theme.smallPadding
|
||||||
color: "black"
|
color: "black"
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: lastChatMessage
|
id: lastChatMessage
|
||||||
text: lastMessage || qsTr("No messages")
|
text: lastMessage || qsTr("No messages")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user