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])
|
self.dataChanged(topLeft, bottomRight, @[ChatMessageRoles.Username.int])
|
||||||
|
|
||||||
proc removeMessagesByUserId*(self: ChatMessageList, publicKey: string) =
|
proc removeMessagesByUserId*(self: ChatMessageList, publicKey: string) =
|
||||||
var msgIdxToDelete: seq[int] = @[]
|
var msgIdxToDelete: seq[string] = @[]
|
||||||
var msgIdToDelete: seq[string] = @[]
|
for m in self.messages.items:
|
||||||
for m in self.messages.mitems:
|
if m.fromAuthor == publicKey: # Can't delete on a loop
|
||||||
if m.fromAuthor == publicKey:
|
msgIdxToDelete.add(m.id)
|
||||||
# Can't delete on a loop
|
|
||||||
msgIdxToDelete.add(self.messageIndex[m.id])
|
|
||||||
msgIdToDelete.add(m.id)
|
|
||||||
for m in msgIdxToDelete:
|
for m in msgIdxToDelete:
|
||||||
self.beginRemoveRows(newQModelIndex(), m, m)
|
self.deleteMessage(m)
|
||||||
self.messages.delete(m)
|
|
||||||
self.endRemoveRows()
|
|
||||||
for m in msgIdToDelete:
|
|
||||||
self.messageIndex.del(m)
|
|
||||||
|
|
||||||
|
|
||||||
proc getID*(self: ChatMessageList):string {.slot.} =
|
proc getID*(self: ChatMessageList):string {.slot.} =
|
||||||
self.id
|
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
|
id: root
|
||||||
width: parent.width
|
width: parent.width
|
||||||
anchors.right: !isCurrentUser ? undefined : parent.right
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
||||||
|
|
Loading…
Reference in New Issue