fix: "Contact / Not a contact" indicator was not being updated when an user was added/removed as contact
This commit is contained in:
parent
6934741081
commit
2da4abf8eb
|
@ -277,8 +277,11 @@ QtObject:
|
||||||
)
|
)
|
||||||
self.contactToAddChanged()
|
self.contactToAddChanged()
|
||||||
|
|
||||||
proc addContact*(self: ProfileView, pk: string): string {.slot.} =
|
proc contactChanged(self: ProfileView, publicKey: string, isAdded: bool) {.signal.}
|
||||||
return self.status.contacts.addContact(pk)
|
|
||||||
|
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.} =
|
proc changeContactNickname*(self: ProfileView, publicKey: string, nickname: string) {.slot.} =
|
||||||
var nicknameToSet = nickname
|
var nicknameToSet = nickname
|
||||||
|
@ -286,11 +289,13 @@ QtObject:
|
||||||
nicknameToSet = DELETE_CONTACT
|
nicknameToSet = DELETE_CONTACT
|
||||||
discard self.status.contacts.addContact(publicKey, nicknameToSet)
|
discard self.status.contacts.addContact(publicKey, nicknameToSet)
|
||||||
|
|
||||||
proc unblockContact*(self: ProfileView, id: string) {.slot.} =
|
proc unblockContact*(self: ProfileView, publicKey: string) {.slot.} =
|
||||||
discard self.status.contacts.unblockContact(id)
|
discard self.status.contacts.unblockContact(publicKey)
|
||||||
|
|
||||||
proc blockContact*(self: ProfileView, id: string): string {.slot.} =
|
proc blockContact*(self: ProfileView, publicKey: string): string {.slot.} =
|
||||||
return self.status.contacts.blockContact(id)
|
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)
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ Rectangle {
|
||||||
Component {
|
Component {
|
||||||
id: chatInfoButton
|
id: chatInfoButton
|
||||||
StatusChatInfoButton {
|
StatusChatInfoButton {
|
||||||
|
chatId: chatsModel.activeChannel.id
|
||||||
chatName: chatsModel.activeChannel.name
|
chatName: chatsModel.activeChannel.name
|
||||||
chatType: chatsModel.activeChannel.chatType
|
chatType: chatsModel.activeChannel.chatType
|
||||||
identicon: chatsModel.activeChannel.identicon
|
identicon: chatsModel.activeChannel.identicon
|
||||||
|
|
|
@ -7,6 +7,7 @@ import "../../shared/status"
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property string chatId
|
||||||
property string chatName
|
property string chatName
|
||||||
property int chatType
|
property int chatType
|
||||||
property string identicon
|
property string identicon
|
||||||
|
@ -48,6 +49,19 @@ Item {
|
||||||
font.pixelSize: 15
|
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 {
|
StyledText {
|
||||||
id: chatInfo
|
id: chatInfo
|
||||||
color: Style.current.darkGrey
|
color: Style.current.darkGrey
|
||||||
|
@ -55,7 +69,7 @@ Item {
|
||||||
switch(root.chatType){
|
switch(root.chatType){
|
||||||
//% "Public chat"
|
//% "Public chat"
|
||||||
case Constants.chatTypePublic: return qsTrId("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"
|
//% "Contact"
|
||||||
qsTrId("chat-is-a-contact") :
|
qsTrId("chat-is-a-contact") :
|
||||||
//% "Not a contact"
|
//% "Not a contact"
|
||||||
|
|
|
@ -7,6 +7,7 @@ import "../../shared/status"
|
||||||
Button {
|
Button {
|
||||||
id: control
|
id: control
|
||||||
|
|
||||||
|
property string chatId
|
||||||
property string chatName
|
property string chatName
|
||||||
property int chatType
|
property int chatType
|
||||||
property string identicon
|
property string identicon
|
||||||
|
@ -20,6 +21,7 @@ Button {
|
||||||
|
|
||||||
contentItem: StatusChatInfo {
|
contentItem: StatusChatInfo {
|
||||||
id: content
|
id: content
|
||||||
|
chatId: control.chatId
|
||||||
chatName: control.chatName
|
chatName: control.chatName
|
||||||
chatType: control.chatType
|
chatType: control.chatType
|
||||||
identicon: control.identicon
|
identicon: control.identicon
|
||||||
|
|
Loading…
Reference in New Issue