Delete chat blocks of an account when removing it.

Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2020-05-06 15:33:51 +02:00
Родитель 632f55b3d1
Коммит 895f38f7cc
3 изменённых файлов: 7 добавлений и 1 удалений

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

@ -21,7 +21,9 @@ extern NSString * const NCChatControllerDidRemoveTemporaryMessagesNotification;
@interface NCChatBlock : RLMObject
@property (nonatomic, strong) NSString *internalId; // same as room internal id
@property (nonatomic, strong) NSString *internalId; // accountId@token (same as room internal id)
@property (nonatomic, strong) NSString *accountId;
@property (nonatomic, strong) NSString *token;
@property (nonatomic, assign) NSInteger oldestMessageId;
@property (nonatomic, assign) NSInteger newestMessageId;
@property (nonatomic, assign) BOOL hasHistory;

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

@ -210,6 +210,8 @@ NSString * const NCChatControllerDidRemoveTemporaryMessagesNotification
// Create new chat block
NCChatBlock *newBlock = [[NCChatBlock alloc] init];
newBlock.internalId = _room.internalId;
newBlock.accountId = _room.accountId;
newBlock.token = _room.token;
newBlock.oldestMessageId = lastKnown;
newBlock.newestMessageId = newestMessageKnown;
newBlock.hasHistory = YES;

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

@ -8,6 +8,7 @@
#import "NCDatabaseManager.h"
#import "NCChatController.h"
#import "NCChatMessage.h"
#import "NCRoom.h"
@ -149,6 +150,7 @@
}
[realm deleteObjects:[NCRoom objectsWithPredicate:query]];
[realm deleteObjects:[NCChatMessage objectsWithPredicate:query]];
[realm deleteObjects:[NCChatBlock objectsWithPredicate:query]];
[realm commitWriteTransaction];
}