Merge pull request #1065 from nextcloud/batch-update-race-condition

Fix race condition in batch update
This commit is contained in:
Ivan Sein 2023-02-03 10:16:37 +01:00 коммит произвёл GitHub
Родитель 351d64b149 e9d81028d7
Коммит e6f258823e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 10 добавлений и 3 удалений

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

@ -2005,8 +2005,14 @@ typedef void (^UpdateCallParticipantViewCellBlock)(CallParticipantViewCell *cell
- (void)removePeer:(NCPeerConnection *)peer
{
dispatch_async(dispatch_get_main_queue(), ^{
[self->_pendingPeerDeletions addObject:peer];
[self scheduleBatchCollectionViewUpdate];
if ([self->_pendingPeerInserts containsObject:peer]) {
// The peer is a pending insert, but was removed before the batch update
// In this case we can just remove the pending insert
[self->_pendingPeerInserts removeObject:peer];
} else {
[self->_pendingPeerDeletions addObject:peer];
[self scheduleBatchCollectionViewUpdate];
}
});
}
@ -2043,7 +2049,8 @@ typedef void (^UpdateCallParticipantViewCellBlock)(CallParticipantViewCell *cell
NSIndexPath *indexPath = [self indexPathForPeerId:peer.peerId];
if (indexPath) {
// Make sure we remove every index path only once
if (indexPath && ![indexPathsToDelete containsObject:indexPath]) {
[indexPathsToDelete addObject:indexPath];
}
}