Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy load room messages #4733

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Riot/Categories/MXRoom+Riot.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ typedef NS_ENUM(NSUInteger, RoomSentStatus)
@property (nonatomic) id notificationCenterDidUpdateObserver;

/// Check if all messages have been sent.
@property (nonatomic, readonly) RoomSentStatus sentStatus;
/// @param completion Completion block
- (void)sentStatusWithCompletion:(void (^)(RoomSentStatus))completion;

/**
Update the room tag.
Expand Down
38 changes: 21 additions & 17 deletions Riot/Categories/MXRoom+Riot.m
Original file line number Diff line number Diff line change
Expand Up @@ -658,28 +658,32 @@ - (id)notificationCenterDidUpdateObserver

#pragma mark - Unread messages

- (RoomSentStatus)sentStatus
- (void)sentStatusWithCompletion:(void (^)(RoomSentStatus))completion
{
RoomSentStatus status = RoomSentStatusOk;
NSArray<MXEvent*> *outgoingMsgs = self.outgoingMessages;

for (MXEvent *event in outgoingMsgs)
{
if (event.sentState == MXEventSentStateFailed)
[self outgoingMessagesWithCompletion:^(NSArray<MXEvent *> * _Nullable outgoingMsgs) {
RoomSentStatus status = RoomSentStatusOk;

for (MXEvent *event in outgoingMsgs)
{
status = RoomSentStatusSentFailed;

// Check if the error is due to unknown devices
if ([event.sentError.domain isEqualToString:MXEncryptingErrorDomain]
&& event.sentError.code == MXEncryptingErrorUnknownDeviceCode)
if (event.sentState == MXEventSentStateFailed)
{
status = RoomSentStatusSentFailedDueToUnknownDevices;
break;
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;

if (completion)
{
completion(status);
}
}];
}

@end
Loading