force messages to dissapear if a contact is blocked
This commit is contained in:
parent
fdf6be5f64
commit
9493839b65
|
@ -287,20 +287,12 @@ QtObject:
|
|||
self.dataChanged(topLeft, bottomRight, @[ChatMessageRoles.Username.int])
|
||||
|
||||
proc removeMessagesByUserId*(self: ChatMessageList, publicKey: string) =
|
||||
var msgIdxToDelete: seq[int] = @[]
|
||||
var msgIdToDelete: seq[string] = @[]
|
||||
for m in self.messages.mitems:
|
||||
if m.fromAuthor == publicKey:
|
||||
# Can't delete on a loop
|
||||
msgIdxToDelete.add(self.messageIndex[m.id])
|
||||
msgIdToDelete.add(m.id)
|
||||
var msgIdxToDelete: seq[string] = @[]
|
||||
for m in self.messages.items:
|
||||
if m.fromAuthor == publicKey: # Can't delete on a loop
|
||||
msgIdxToDelete.add(m.id)
|
||||
for m in msgIdxToDelete:
|
||||
self.beginRemoveRows(newQModelIndex(), m, m)
|
||||
self.messages.delete(m)
|
||||
self.endRemoveRows()
|
||||
for m in msgIdToDelete:
|
||||
self.messageIndex.del(m)
|
||||
|
||||
self.deleteMessage(m)
|
||||
|
||||
proc getID*(self: ChatMessageList):string {.slot.} =
|
||||
self.id
|
|
@ -135,6 +135,17 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: profileModel.contacts
|
||||
onContactBlocked: {
|
||||
// This hack is used because removeMessagesByUserId sometimes does not remove the messages
|
||||
if(publicKey === fromAuthor){
|
||||
root.visible = 0;
|
||||
root.height = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
id: root
|
||||
width: parent.width
|
||||
anchors.right: !isCurrentUser ? undefined : parent.right
|
||||
|
|
Loading…
Reference in New Issue