fix: "Contact / Not a contact" indicator was not being updated when an user was added/removed as contact

This commit is contained in:
Richard Ramos 2020-10-02 15:25:33 -04:00 committed by Iuri Matias
parent 6934741081
commit 2da4abf8eb
4 changed files with 31 additions and 9 deletions

View File

@ -277,8 +277,11 @@ QtObject:
)
self.contactToAddChanged()
proc addContact*(self: ProfileView, pk: string): string {.slot.} =
return self.status.contacts.addContact(pk)
proc contactChanged(self: ProfileView, publicKey: string, isAdded: bool) {.signal.}
proc addContact*(self: ProfileView, publicKey: string): string {.slot.} =
result = self.status.contacts.addContact(publicKey)
self.contactChanged(publicKey, true)
proc changeContactNickname*(self: ProfileView, publicKey: string, nickname: string) {.slot.} =
var nicknameToSet = nickname
@ -286,11 +289,13 @@ QtObject:
nicknameToSet = DELETE_CONTACT
discard self.status.contacts.addContact(publicKey, nicknameToSet)
proc unblockContact*(self: ProfileView, id: string) {.slot.} =
discard self.status.contacts.unblockContact(id)
proc unblockContact*(self: ProfileView, publicKey: string) {.slot.} =
discard self.status.contacts.unblockContact(publicKey)
proc blockContact*(self: ProfileView, id: string): string {.slot.} =
return self.status.contacts.blockContact(id)
proc blockContact*(self: ProfileView, publicKey: string): string {.slot.} =
return self.status.contacts.blockContact(publicKey)
proc removeContact*(self: ProfileView, publicKey: string) {.slot.} =
self.status.contacts.removeContact(publicKey)
self.contactChanged(publicKey, false)
proc removeContact*(self: ProfileView, id: string) {.slot.} =
self.status.contacts.removeContact(id)

View File

@ -28,6 +28,7 @@ Rectangle {
Component {
id: chatInfoButton
StatusChatInfoButton {
chatId: chatsModel.activeChannel.id
chatName: chatsModel.activeChannel.name
chatType: chatsModel.activeChannel.chatType
identicon: chatsModel.activeChannel.identicon

View File

@ -7,6 +7,7 @@ import "../../shared/status"
Item {
id: root
property string chatId
property string chatName
property int chatType
property string identicon
@ -48,6 +49,19 @@ Item {
font.pixelSize: 15
}
Connections {
target: profileModel
onContactChanged: {
if(root.chatId === publicKey){
// Hack warning: Triggering reload to avoid changing the current text binding
var tmp = chatId;
chatId = "";
chatId = tmp;
}
}
}
StyledText {
id: chatInfo
color: Style.current.darkGrey
@ -55,7 +69,7 @@ Item {
switch(root.chatType){
//% "Public chat"
case Constants.chatTypePublic: return qsTrId("public-chat")
case Constants.chatTypeOneToOne: return (profileModel.isAdded(root.chatName) ?
case Constants.chatTypeOneToOne: return (profileModel.isAdded(root.chatId) ?
//% "Contact"
qsTrId("chat-is-a-contact") :
//% "Not a contact"

View File

@ -7,6 +7,7 @@ import "../../shared/status"
Button {
id: control
property string chatId
property string chatName
property int chatType
property string identicon
@ -20,6 +21,7 @@ Button {
contentItem: StatusChatInfo {
id: content
chatId: control.chatId
chatName: control.chatName
chatType: control.chatType
identicon: control.identicon