mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-22 03:28: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.status.events.on("channelJoined") do(e: Args):
|
||||
var channelMessage = ChannelArgs(e)
|
||||
let chatItem = newChatItem(id = channelMessage.channel, channelMessage.chatTypeInt)
|
||||
var channel = ChannelArgs(e)
|
||||
let chatItem = newChatItem(id = channel.channel, name = channel.name, chatType = channel.chatTypeInt)
|
||||
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):
|
||||
discard self.view.chats.removeChatItemFromList(self.view.activeChannel.chatItem.id)
|
||||
|
@ -12,6 +12,7 @@ type
|
||||
UnreadMessages = UserRole + 4
|
||||
Identicon = UserRole + 5
|
||||
ChatType = UserRole + 6
|
||||
Color = UserRole + 7
|
||||
|
||||
QtObject:
|
||||
type
|
||||
@ -44,6 +45,7 @@ QtObject:
|
||||
of ChannelsRoles.UnreadMessages: result = newQVariant(chatItem.unviewedMessagesCount)
|
||||
of ChannelsRoles.Identicon: result = newQVariant(chatItem.identicon)
|
||||
of ChannelsRoles.ChatType: result = newQVariant(chatItem.chatType.int)
|
||||
of ChannelsRoles.Color: result = newQVariant(chatItem.color)
|
||||
|
||||
method roleNames(self: ChannelsList): Table[int, string] =
|
||||
{
|
||||
@ -52,7 +54,8 @@ QtObject:
|
||||
ChannelsRoles.LastMessage.int: "lastMessage",
|
||||
ChannelsRoles.UnreadMessages.int: "unviewedMessagesCount",
|
||||
ChannelsRoles.Identicon.int: "identicon",
|
||||
ChannelsRoles.ChatType.int: "chatType"
|
||||
ChannelsRoles.ChatType.int: "chatType",
|
||||
ChannelsRoles.Color.int: "color"
|
||||
}.toTable
|
||||
|
||||
proc addChatItemToList*(self: ChannelsList, channel: ChatItem): int =
|
||||
@ -62,7 +65,7 @@ QtObject:
|
||||
self.beginInsertRows(newQModelIndex(), 0, 0)
|
||||
self.chats.insert(channel, 0)
|
||||
self.endInsertRows()
|
||||
result = self.chats.len - 1
|
||||
result = 0
|
||||
|
||||
proc removeChatItemFromList*(self: ChannelsList, channel: string): int =
|
||||
let idx = self.chats.findById(channel)
|
||||
@ -90,20 +93,20 @@ QtObject:
|
||||
proc updateChat*(self: ChannelsList, channel: ChatItem) =
|
||||
let idx = self.upsertChannel(channel)
|
||||
let topLeft = self.createIndex(0, 0, nil)
|
||||
let bottomRight = self.createIndex(self.chats.len - 1, 0, nil)
|
||||
if(idx != 0): # Move last updated chat to the top of the list
|
||||
self.chats.del(idx)
|
||||
let bottomRight = self.createIndex(self.chats.len, 0, nil)
|
||||
if idx != 0: # Move last updated chat to the top of the list
|
||||
self.chats.delete(idx)
|
||||
self.chats.insert(channel, 0)
|
||||
else:
|
||||
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) =
|
||||
let idx = self.chats.findById(channel.id)
|
||||
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
|
||||
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
|
||||
channel*: string
|
||||
name*: string
|
||||
chatTypeInt*: ChatType
|
||||
|
||||
ChatArgs* = ref object of Args
|
||||
@ -69,7 +70,7 @@ proc join*(self: ChatModel, chatId: string, chatType: ChatType) =
|
||||
else:
|
||||
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()))
|
||||
|
||||
proc init*(self: ChatModel) =
|
||||
@ -80,7 +81,7 @@ proc init*(self: ChatModel) =
|
||||
if self.hasChannel(chat.id): continue
|
||||
filters.add status_chat.buildFilter(chatId = chat.id, oneToOne = chat.chatType.isOneToOne)
|
||||
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
|
||||
|
||||
|
@ -11,13 +11,13 @@ type ChatItem* = ref object
|
||||
color*: 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)
|
||||
result.id = id
|
||||
result.name = case chatType
|
||||
of ChatType.Public: id
|
||||
of ChatType.Public: name
|
||||
of ChatType.OneToOne: generateAlias(id)
|
||||
of ChatType.PrivateGroupChat: "TODO: Private Group Name"
|
||||
of ChatType.PrivateGroupChat: name
|
||||
of ChatType.Unknown: "Unknown: " & id
|
||||
result.chatType = chatType
|
||||
result.lastMessage = lastMessage
|
||||
@ -42,7 +42,7 @@ proc chatName(chat: Chat): string =
|
||||
case chat.chatType
|
||||
of ChatType.OneToOne: result = chat.lastMessage.alias
|
||||
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"
|
||||
|
||||
proc toChatItem*(chat: Chat): ChatItem =
|
||||
|
@ -24,7 +24,7 @@ Item {
|
||||
height: {
|
||||
switch(contentType){
|
||||
case Constants.chatIdentifier:
|
||||
return parent.parent.height
|
||||
return parent.parent.height - 100
|
||||
case Constants.stickerType:
|
||||
return stickerId.height + 50
|
||||
default:
|
||||
@ -70,13 +70,7 @@ Item {
|
||||
|
||||
Text {
|
||||
visible: chatsModel.activeChannel.chatType != Constants.chatTypeOneToOne
|
||||
text: {
|
||||
if (chatsModel.activeChannel.chatType == Constants.chatTypeOneToOne) {
|
||||
return chatsModel.activeChannel.name;
|
||||
} else {
|
||||
return (chatId.charAt(0) == "#" ? chatId.charAt(1) : chatId.charAt(0)).toUpperCase();
|
||||
}
|
||||
}
|
||||
text: (chatsModel.activeChannel.name.charAt(0) == "#" ? chatsModel.activeChannel.name.charAt(1) : chatsModel.activeChannel.name.charAt(0)).toUpperCase()
|
||||
opacity: 0.7
|
||||
font.weight: Font.Bold
|
||||
font.pixelSize: 51
|
||||
@ -89,10 +83,10 @@ Item {
|
||||
Text {
|
||||
wrapMode: Text.Wrap
|
||||
text: {
|
||||
if (chatsModel.activeChannel.chatType == Constants.chatTypeOneToOne) {
|
||||
if (chatsModel.activeChannel.chatType != Constants.chatTypePublic) {
|
||||
return chatsModel.activeChannel.name;
|
||||
} else {
|
||||
return "#" + chatId;
|
||||
return "#" + chatsModel.activeChannel.name;
|
||||
}
|
||||
}
|
||||
font.weight: Font.Bold
|
||||
|
@ -29,7 +29,7 @@ Rectangle {
|
||||
id: channelName
|
||||
width: 80
|
||||
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.leftMargin: Theme.smallPadding
|
||||
anchors.top: parent.top
|
||||
@ -44,7 +44,13 @@ Rectangle {
|
||||
id: channelIdentifier
|
||||
color: Theme.darkGrey
|
||||
// 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
|
||||
anchors.left: channelIcon.right
|
||||
anchors.leftMargin: Theme.smallPadding
|
||||
|
@ -43,7 +43,7 @@ Rectangle {
|
||||
|
||||
Text {
|
||||
id: contactInfo
|
||||
text: chatType == Constants.chatTypeOneToOne ? name : "#" + name
|
||||
text: chatType != Constants.chatTypePublic ? name : "#" + name
|
||||
anchors.right: contactTime.left
|
||||
anchors.rightMargin: Theme.smallPadding
|
||||
elide: Text.ElideRight
|
||||
@ -55,6 +55,7 @@ Rectangle {
|
||||
anchors.topMargin: Theme.smallPadding
|
||||
color: "black"
|
||||
}
|
||||
|
||||
Text {
|
||||
id: lastChatMessage
|
||||
text: lastMessage || qsTr("No messages")
|
||||
|
Loading…
x
Reference in New Issue
Block a user