fix: update chat view after user is blocked
This commit is contained in:
parent
8fd28dfad6
commit
f69da599ae
|
@ -123,6 +123,12 @@ QtObject:
|
|||
read = getBlockedContacts
|
||||
notify = contactListChanged
|
||||
|
||||
proc isContactBlocked*(self: ProfileView, pubkey: string): bool {.slot.} =
|
||||
for contact in self.blockedContacts.contacts:
|
||||
if contact.id == pubkey:
|
||||
return true
|
||||
return false
|
||||
|
||||
proc isMnemonicBackedUp*(self: ProfileView): bool {.slot.} =
|
||||
let mnemonic = status_settings.getSetting[string](Setting.Mnemonic, "")
|
||||
return mnemonic == ""
|
||||
|
@ -337,9 +343,11 @@ QtObject:
|
|||
discard self.status.contacts.addContact(publicKey, nicknameToSet)
|
||||
|
||||
proc unblockContact*(self: ProfileView, publicKey: string) {.slot.} =
|
||||
self.contactListChanged()
|
||||
discard self.status.contacts.unblockContact(publicKey)
|
||||
|
||||
proc blockContact*(self: ProfileView, publicKey: string): string {.slot.} =
|
||||
self.contactListChanged()
|
||||
return self.status.contacts.blockContact(publicKey)
|
||||
|
||||
proc removeContact*(self: ProfileView, publicKey: string) {.slot.} =
|
||||
|
|
|
@ -28,7 +28,8 @@ StackLayout {
|
|||
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||
}
|
||||
|
||||
property bool isBlocked: Utils.isContactBlocked(chatsModel.activeChannel.id, profileModel.getBlockedContacts())
|
||||
property bool isBlocked: profileModel.isContactBlocked(chatsModel.activeChannel.id)
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||
|
@ -70,6 +71,13 @@ StackLayout {
|
|||
txModalLoader.close()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: profileModel
|
||||
onContactListChanged: {
|
||||
console.log("Contact list changed");
|
||||
isBlocked = profileModel.isContactBlocked(chatsModel.activeChannel.id);
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
|
@ -239,7 +247,9 @@ StackLayout {
|
|||
return chatsModel.activeChannel.isMember
|
||||
}
|
||||
enabled: !isBlocked
|
||||
chatInputPlaceholder: isBlocked ? qsTr("This user has been blocked.") : qsTr("Type a message.")
|
||||
chatInputPlaceholder: isBlocked ?
|
||||
qsTr("This user has been blocked.") :
|
||||
qsTr("Type a message.")
|
||||
anchors.bottom: parent.bottom
|
||||
recentStickers: chatsModel.recentStickers
|
||||
stickerPackList: chatsModel.stickerPacks
|
||||
|
|
|
@ -40,7 +40,7 @@ ModalPopup {
|
|||
identicon = identiconParam || ""
|
||||
text = textParam || ""
|
||||
isEnsVerified = chatsModel.isEnsVerified(this.fromAuthor)
|
||||
isBlocked = Utils.isContactBlocked(this.fromAuthor, profileModel.getBlockedContacts());
|
||||
isBlocked = profileModel.isContactBlocked(this.fromAuthor);
|
||||
alias = chatsModel.alias(this.fromAuthor) || ""
|
||||
|
||||
showQR = false
|
||||
|
@ -392,7 +392,9 @@ ModalPopup {
|
|||
btnBorderWidth: 1
|
||||
btnBorderColor: Style.current.grey
|
||||
textColor: Style.current.red
|
||||
label: isBlocked ? qsTr("Unblock User") : qsTr("Block User")
|
||||
label: isBlocked ?
|
||||
qsTr("Unblock User") :
|
||||
qsTr("Block User")
|
||||
anchors.bottom: parent.bottom
|
||||
onClicked: {
|
||||
if (isBlocked) {
|
||||
|
|
|
@ -197,13 +197,4 @@ QtObject {
|
|||
default: return network
|
||||
}
|
||||
}
|
||||
|
||||
function isContactBlocked(fromAuthor, blockedList) {
|
||||
for (let i = 0; i < blockedList.rowCount(); i++) {
|
||||
if (blockedList.rowData(i, 'pubKey') === fromAuthor) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ Rectangle {
|
|||
|
||||
property int chatType
|
||||
|
||||
property string chatInputPlaceholder: qsTr("Type a message")
|
||||
property string chatInputPlaceholder: qsTr("Type a message.")
|
||||
|
||||
property alias textInput: messageInputField
|
||||
|
||||
|
|
Loading…
Reference in New Issue