Use new apis

This commit is contained in:
ismailgulek 2021-06-01 17:54:49 +03:00
parent b4f8f4f5ef
commit 31587a0c3e
No known key found for this signature in database
GPG key ID: E96336D42D9470A9
2 changed files with 23 additions and 9 deletions

View file

@ -88,19 +88,33 @@ static const CGFloat kDirectRoomBorderWidth = 3.0;
{
// Report computed values as is
self.roomTitle.text = roomCellData.roomDisplayname;
self.lastEventDate.text = roomCellData.lastEventDate;
MXWeakify(self);
[roomCellData lastEventDateString:^(NSString *dateString) {
MXStrongifyAndReturnIfNil(self);
self.lastEventDate.text = dateString;
}];
// Manage lastEventAttributedTextMessage optional property
if ([roomCellData respondsToSelector:@selector(lastEventAttributedTextMessage)])
if ([roomCellData respondsToSelector:@selector(lastEventAttributedText:)])
{
// Force the default text color for the last message (cancel highlighted message color)
NSMutableAttributedString *lastEventDescription = [[NSMutableAttributedString alloc] initWithAttributedString:roomCellData.lastEventAttributedTextMessage];
[lastEventDescription addAttribute:NSForegroundColorAttributeName value:ThemeService.shared.theme.textSecondaryColor range:NSMakeRange(0, lastEventDescription.length)];
self.lastEventDescription.attributedText = lastEventDescription;
MXWeakify(self);
[roomCellData lastEventAttributedText:^(NSAttributedString *attributedText) {
MXStrongifyAndReturnIfNil(self);
// Force the default text color for the last message (cancel highlighted message color)
NSMutableAttributedString *lastEventDescription = [[NSMutableAttributedString alloc] initWithAttributedString:attributedText];
[lastEventDescription addAttribute:NSForegroundColorAttributeName
value:ThemeService.shared.theme.textSecondaryColor
range:NSMakeRange(0, lastEventDescription.length)];
self.lastEventDescription.attributedText = lastEventDescription;
}];
}
else
{
self.lastEventDescription.text = roomCellData.lastEventTextMessage;
MXWeakify(self);
[roomCellData lastEventText:^(NSString *text) {
MXStrongifyAndReturnIfNil(self);
self.lastEventDescription.text = text;
}];
}
self.unsentImageView.hidden = roomCellData.roomSummary.room.sentStatus == RoomSentStatusOk;

View file

@ -76,11 +76,11 @@
NSComparator comparator = ^NSComparisonResult(MXKRecentCellData *recentCellData1, MXKRecentCellData *recentCellData2) {
NSComparisonResult result = NSOrderedAscending;
if (recentCellData2.roomSummary.lastMessageOriginServerTs > recentCellData1.roomSummary.lastMessageOriginServerTs)
if (recentCellData2.roomSummary.lastMessage.originServerTs > recentCellData1.roomSummary.lastMessage.originServerTs)
{
result = NSOrderedDescending;
}
else if (recentCellData2.roomSummary.lastMessageOriginServerTs == recentCellData1.roomSummary.lastMessageOriginServerTs)
else if (recentCellData2.roomSummary.lastMessage.originServerTs == recentCellData1.roomSummary.lastMessage.originServerTs)
{
result = NSOrderedSame;
}