Adapt sentStatus changes

This commit is contained in:
ismailgulek 2021-09-22 11:41:22 +03:00
parent 1241ca8a88
commit c71386a2ba
No known key found for this signature in database
GPG key ID: E96336D42D9470A9
5 changed files with 12 additions and 46 deletions

View file

@ -19,13 +19,6 @@
#import "UserEncryptionTrustLevel.h"
typedef NS_ENUM(NSUInteger, RoomSentStatus)
{
RoomSentStatusOk,
RoomSentStatusSentFailed,
RoomSentStatusSentFailedDueToUnknownDevices
};
/**
Define a `MXRoom` category at Riot level.
*/
@ -51,9 +44,6 @@ typedef NS_ENUM(NSUInteger, RoomSentStatus)
*/
@property (nonatomic) id notificationCenterDidUpdateObserver;
/// Check if all messages have been sent.
@property (nonatomic, readonly) RoomSentStatus sentStatus;
/**
Update the room tag.

View file

@ -656,30 +656,4 @@
return objc_getAssociatedObject(self, @selector(notificationCenterDidUpdateObserver));
}
#pragma mark - Unread messages
- (RoomSentStatus)sentStatus
{
RoomSentStatus status = RoomSentStatusOk;
NSArray<MXEvent*> *outgoingMsgs = self.outgoingMessages;
for (MXEvent *event in outgoingMsgs)
{
if (event.sentState == MXEventSentStateFailed)
{
status = RoomSentStatusSentFailed;
// Check if the error is due to unknown devices
if ([event.sentError.domain isEqualToString:MXEncryptingErrorDomain]
&& event.sentError.code == MXEncryptingErrorUnknownDeviceCode)
{
status = RoomSentStatusSentFailedDueToUnknownDevices;
break;
}
}
}
return status;
}
@end

View file

@ -88,7 +88,8 @@
self.lastEventDescription.text = roomCellData.lastEventTextMessage;
}
self.unsentImageView.hidden = roomCellData.roomSummary.room.sentStatus == RoomSentStatusOk;
MXRoom *room = [roomCellData.mxSession roomWithRoomId:roomCellData.roomSummary.roomId];
self.unsentImageView.hidden = roomCellData.roomSummary.sentStatus == MXRoomSummarySentStatusOk;
self.lastEventDecriptionLabelTrailingConstraint.constant = self.unsentImageView.hidden ? 10 : 30;
// Notify unreads and bing
@ -124,7 +125,7 @@
self.roomTitle.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium];
}
[roomCellData.roomSummary setRoomAvatarImageIn:self.roomAvatar];
[room.summary setRoomAvatarImageIn:self.roomAvatar];
}
else
{

View file

@ -101,8 +101,8 @@
}
// Notify unreads and bing
if (roomCellData.roomSummary.room.summary.membership == MXMembershipInvite
|| roomCellData.roomSummary.room.sentStatus != RoomSentStatusOk)
if (roomCellData.roomSummary.membership == MXMembershipInvite
|| roomCellData.roomSummary.sentStatus != MXRoomSummarySentStatusOk)
{
self.badgeLabel.hidden = NO;
self.badgeLabel.badgeColor = ThemeService.shared.theme.noticeColor;
@ -130,7 +130,8 @@
}
[roomCellData.roomSummary setRoomAvatarImageIn:self.roomAvatar];
MXRoom *room = [roomCellData.mxSession roomWithRoomId:roomCellData.roomSummary.roomId];
[room.summary setRoomAvatarImageIn:self.roomAvatar];
}
}

View file

@ -4993,14 +4993,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
-(BOOL)checkUnsentMessages
{
RoomSentStatus sentStatus = RoomSentStatusOk;
MXRoomSummarySentStatus sentStatus = MXRoomSummarySentStatusOk;
if ([self.activitiesView isKindOfClass:RoomActivitiesView.class])
{
sentStatus = self.roomDataSource.room.sentStatus;
sentStatus = self.roomDataSource.room.summary.sentStatus;
if (sentStatus != RoomSentStatusOk)
if (sentStatus != MXRoomSummarySentStatusOk)
{
NSString *notification = sentStatus == RoomSentStatusSentFailedDueToUnknownDevices ?
NSString *notification = sentStatus == MXRoomSummarySentStatusSentFailedDueToUnknownDevices ?
NSLocalizedStringFromTable(@"room_unsent_messages_unknown_devices_notification", @"Vector", nil) :
NSLocalizedStringFromTable(@"room_unsent_messages_notification", @"Vector", nil);
@ -5071,7 +5071,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
}
}
return sentStatus != RoomSentStatusOk;
return sentStatus != MXRoomSummarySentStatusOk;
}
- (void)eventDidChangeSentState:(NSNotification *)notif