mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Merge pull request #2506 from vector-im/aggregation_and_readreceipts
Read receipts: They are now counted at the MatrixKit level.
This commit is contained in:
commit
e0dc912a0b
3 changed files with 1 additions and 90 deletions
|
@ -10,6 +10,7 @@ Improvements:
|
|||
* Context menu polish (#2466).
|
||||
* Message Editing: Annotate edited messages in timeline (#2400).
|
||||
* Message Editing: Editing in the timeline (#2404).
|
||||
* Read receipts: They are now counted at the MatrixKit level.
|
||||
|
||||
Bug fix:
|
||||
* Device Verification: Fix user display name and device id colors in dark theme
|
||||
|
|
|
@ -71,10 +71,6 @@ static NSAttributedString *timestampVerticalWhitespace = nil;
|
|||
|
||||
// Increase maximum number of components
|
||||
self.maxComponentCount = 20;
|
||||
|
||||
// Initialize read receipts
|
||||
self.readReceipts = [NSMutableDictionary dictionary];
|
||||
self.readReceipts[event.eventId] = [roomDataSource.room getEventReceipts:event.eventId sorted:YES];
|
||||
|
||||
// Reset attributedTextMessage to force reset MXKRoomCellData parameters
|
||||
self.attributedTextMessage = nil;
|
||||
|
@ -550,9 +546,6 @@ static NSAttributedString *timestampVerticalWhitespace = nil;
|
|||
return NO;
|
||||
}
|
||||
|
||||
// Update read receipts for this bubble
|
||||
self.readReceipts[event.eventId] = [roomDataSource.room getEventReceipts:event.eventId sorted:YES];
|
||||
|
||||
return [super addEvent:event andRoomState:roomState];
|
||||
}
|
||||
|
||||
|
|
|
@ -120,89 +120,6 @@
|
|||
[super destroy];
|
||||
}
|
||||
|
||||
- (void)didReceiveReceiptEvent:(MXEvent *)receiptEvent roomState:(MXRoomState *)roomState
|
||||
{
|
||||
// Do the processing on the same processing queue as MXKRoomDataSource
|
||||
dispatch_async(MXKRoomDataSource.processingQueue, ^{
|
||||
|
||||
// Remove the previous displayed read receipt for each user who sent a
|
||||
// new read receipt.
|
||||
// To implement it, we need to find the sender id of each new read receipt
|
||||
// among the read receipts array of all events in all bubbles.
|
||||
NSArray *readReceiptSenders = receiptEvent.readReceiptSenders;
|
||||
|
||||
@synchronized(bubbles)
|
||||
{
|
||||
for (RoomBubbleCellData *cellData in bubbles)
|
||||
{
|
||||
NSMutableDictionary<NSString* /* eventId */, NSArray<MXReceiptData*> *> *updatedCellDataReadReceipts = [NSMutableDictionary dictionary];
|
||||
|
||||
for (NSString *eventId in cellData.readReceipts)
|
||||
{
|
||||
for (MXReceiptData *receiptData in cellData.readReceipts[eventId])
|
||||
{
|
||||
for (NSString *senderId in readReceiptSenders)
|
||||
{
|
||||
if ([receiptData.userId isEqualToString:senderId])
|
||||
{
|
||||
if (!updatedCellDataReadReceipts[eventId])
|
||||
{
|
||||
updatedCellDataReadReceipts[eventId] = cellData.readReceipts[eventId];
|
||||
}
|
||||
|
||||
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"userId!=%@", receiptData.userId];
|
||||
updatedCellDataReadReceipts[eventId] = [updatedCellDataReadReceipts[eventId] filteredArrayUsingPredicate:predicate];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Flush found changed to the cell data
|
||||
for (NSString *eventId in updatedCellDataReadReceipts)
|
||||
{
|
||||
if (updatedCellDataReadReceipts[eventId].count)
|
||||
{
|
||||
cellData.readReceipts[eventId] = updatedCellDataReadReceipts[eventId];
|
||||
}
|
||||
else
|
||||
{
|
||||
cellData.readReceipts[eventId] = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update cell data we have received a read receipt for
|
||||
NSArray *readEventIds = receiptEvent.readReceiptEventIds;
|
||||
for (NSString* eventId in readEventIds)
|
||||
{
|
||||
RoomBubbleCellData *cellData = [self cellDataOfEventWithEventId:eventId];
|
||||
if (cellData)
|
||||
{
|
||||
@synchronized(bubbles)
|
||||
{
|
||||
if (!cellData.hasNoDisplay)
|
||||
{
|
||||
cellData.readReceipts[eventId] = [self.room getEventReceipts:eventId sorted:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore the read receipts on the events without an actual display.
|
||||
cellData.readReceipts[eventId] = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// TODO: Be smarter and update only updated cells
|
||||
[super didReceiveReceiptEvent:receiptEvent roomState:roomState];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
|
|
Loading…
Reference in a new issue