Skip to content

Commit

Permalink
Bug Fix: Resend now function doesn't work on canceled upload file
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Dec 26, 2016
1 parent 561ff62 commit d2946d6
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,19 @@ - (MXHTTPOperation*)sendImage:(NSData*)imageData

void(^onFailure)(NSError *) = ^(NSError *error) {

// Update the local echo with the error state (This will trigger kMXEventDidChangeSentStateNotification notification).
event.sentState = MXEventSentStateFailed;

// Update the stored echo.
[self updateOutgoingMessage:event.eventId withOutgoingMessage:event];
// Remove outgoing message when its sent has been cancelled
if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)
{
[self removeOutgoingMessage:event.eventId];
}
else
{
// Update the local echo with the error state (This will trigger kMXEventDidChangeSentStateNotification notification).
event.sentState = MXEventSentStateFailed;

// Update the stored echo.
[self updateOutgoingMessage:event.eventId withOutgoingMessage:event];
}

if (uploaderObserver)
{
Expand Down Expand Up @@ -772,11 +780,19 @@ - (MXHTTPOperation*)sendVideo:(NSURL*)videoLocalURL

void(^onFailure)(NSError *) = ^(NSError *error) {

// Update the local echo with the error state (This will trigger kMXEventDidChangeSentStateNotification notification).
event.sentState = MXEventSentStateFailed;

// Update the stored echo.
[self updateOutgoingMessage:event.eventId withOutgoingMessage:event];
// Remove outgoing message when its sent has been cancelled
if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)
{
[self removeOutgoingMessage:event.eventId];
}
else
{
// Update the local echo with the error state (This will trigger kMXEventDidChangeSentStateNotification notification).
event.sentState = MXEventSentStateFailed;

// Update the stored echo.
[self updateOutgoingMessage:event.eventId withOutgoingMessage:event];
}

if (uploaderObserver)
{
Expand Down Expand Up @@ -988,11 +1004,19 @@ - (MXHTTPOperation*)sendFile:(NSURL*)fileLocalURL

void(^onFailure)(NSError *) = ^(NSError *error) {

// Update the local echo with the error state (This will trigger kMXEventDidChangeSentStateNotification notification).
event.sentState = MXEventSentStateFailed;

// Update the stored echo.
[self updateOutgoingMessage:event.eventId withOutgoingMessage:event];
// Remove outgoing message when its sent has been cancelled
if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled)
{
[self removeOutgoingMessage:event.eventId];
}
else
{
// Update the local echo with the error state (This will trigger kMXEventDidChangeSentStateNotification notification).
event.sentState = MXEventSentStateFailed;

// Update the stored echo.
[self updateOutgoingMessage:event.eventId withOutgoingMessage:event];
}

if (uploaderObserver)
{
Expand Down

0 comments on commit d2946d6

Please sign in to comment.