Make sure query is unique when querying temporary messages

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
This commit is contained in:
Marcel Müller 2020-12-28 17:05:04 +01:00
Родитель ca4c49cb55
Коммит fdc4debe45
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -124,7 +124,7 @@ NSString * const NCChatControllerDidRemoveTemporaryMessagesNotification
message.parentId = parent.internalId;
if (message.referenceId && ![message.referenceId isEqualToString:@""]) {
NCChatMessage *managedTemporaryMessage = [NCChatMessage objectsWhere:@"referenceId = %@", message.referenceId].firstObject;
NCChatMessage *managedTemporaryMessage = [NCChatMessage objectsWhere:@"referenceId = %@ AND isTemporary = true", message.referenceId].firstObject;
if (managedTemporaryMessage) {
[realm deleteObject:managedTemporaryMessage];
// Create a unmanaged copy of message, since 'message' will point to a managed object when added to the DB.
@ -271,7 +271,7 @@ NSString * const NCChatControllerDidRemoveTemporaryMessagesNotification
{
RLMRealm *realm = [RLMRealm defaultRealm];
[realm transactionWithBlock:^{
NCChatMessage *managedChatMessage = [NCChatMessage objectsWhere:@"referenceId = %@", referenceId].firstObject;
NCChatMessage *managedChatMessage = [NCChatMessage objectsWhere:@"referenceId = %@ AND isTemporary = true", referenceId].firstObject;
managedChatMessage.sendingFailed = YES;
}];
}

Просмотреть файл

@ -654,7 +654,7 @@ NSString * const NCChatViewControllerReplyPrivatelyNotification = @"NCChatViewCo
{
RLMRealm *realm = [RLMRealm defaultRealm];
[realm transactionWithBlock:^{
NCChatMessage *managedTemporaryMessage = [NCChatMessage objectsWhere:@"referenceId = %@", temporaryMessage.referenceId].firstObject;
NCChatMessage *managedTemporaryMessage = [NCChatMessage objectsWhere:@"referenceId = %@ AND isTemporary = true", temporaryMessage.referenceId].firstObject;
if (managedTemporaryMessage) {
[realm deleteObject:managedTemporaryMessage];
}