diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 706af7aa4..208c1f75b 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -253,7 +253,7 @@ "room_event_action_save" = "Save"; "room_event_action_resend" = "Resend"; "room_event_action_delete" = "Delete"; -"room_event_action_cancel_upload" = "Cancel Upload"; +"room_event_action_cancel_send" = "Cancel Send"; "room_event_action_cancel_download" = "Cancel Download"; "room_event_action_view_encryption" = "Encryption Information"; "room_warning_about_encryption" = "End-to-end encryption is in beta and may not be reliable.\n\nYou should not yet trust it to secure data.\n\nDevices will not yet be able to decrypt history from before they joined the room.\n\nEncrypted messages will not be visible on clients that do not yet implement encryption."; diff --git a/Riot/Assets/fr.lproj/Vector.strings b/Riot/Assets/fr.lproj/Vector.strings index c91143745..e0fcc3426 100644 --- a/Riot/Assets/fr.lproj/Vector.strings +++ b/Riot/Assets/fr.lproj/Vector.strings @@ -210,7 +210,7 @@ "room_event_action_save" = "Enregistrer"; "room_event_action_resend" = "Renvoyer"; "room_event_action_delete" = "Supprimer"; -"room_event_action_cancel_upload" = "Annuler l'envoi"; +"room_event_action_cancel_send" = "Annuler l'envoi"; "room_event_action_cancel_download" = "Annuler le téléchargement"; "room_event_action_view_encryption" = "Informations sur le chiffrement"; "room_warning_about_encryption" = "Le chiffrement de bout en bout est en version bêta et peut ne pas être fiable.\n\nIl ne doit pas être considéré comme fiable pour sécuriser des données.\n\nLes appareils ne pourront pas encore déchiffrer l'historique de messages d'avant leur arrivée sur le salon.\n\nLes messages chiffrés ne seront pas visibles sur les clients qui n'ont pas encore implémenté le chiffrement."; diff --git a/Riot/ViewController/RoomViewController.m b/Riot/ViewController/RoomViewController.m index 81413a5f3..e0286d891 100644 --- a/Riot/ViewController/RoomViewController.m +++ b/Riot/ViewController/RoomViewController.m @@ -1945,6 +1945,34 @@ selectedComponent = nil; } + if (level == 0) + { + // Check status of the selected event + if (selectedEvent.sentState == MXEventSentStatePreparing || + selectedEvent.sentState == MXEventSentStateEncrypting || + selectedEvent.sentState == MXEventSentStateSending) + { + [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_event_action_cancel_send", @"Vector", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) + { + if (weakSelf) + { + typeof(self) self = weakSelf; + + self->currentAlert = nil; + + // Cancel and remove the outgoing message + [self.roomDataSource.room cancelSendingOperation:selectedEvent.eventId]; + [self.roomDataSource removeEventWithEventId:selectedEvent.eventId]; + + [self cancelEventSelection]; + } + + }]]; + } + } + if (level == 0) { [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_event_action_copy", @"Vector", nil) @@ -2087,18 +2115,17 @@ // Check status of the selected event if (selectedEvent.sentState == MXEventSentStatePreparing || selectedEvent.sentState == MXEventSentStateEncrypting || - selectedEvent.sentState == MXEventSentStateUploading) + selectedEvent.sentState == MXEventSentStateUploading || + selectedEvent.sentState == MXEventSentStateSending) { // Upload id is stored in attachment url (nasty trick) NSString *uploadId = roomBubbleTableViewCell.bubbleData.attachment.actualURL; if ([MXMediaManager existingUploaderWithId:uploadId]) { - [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_event_action_cancel_upload", @"Vector", nil) + [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_event_action_cancel_send", @"Vector", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - - // TODO cancel the attachment encryption if it is in progress. - + // Get again the loader MXMediaLoader *loader = [MXMediaManager existingUploaderWithId:uploadId]; if (loader) @@ -2117,6 +2144,9 @@ // Remove the outgoing message and its related cached file. [[NSFileManager defaultManager] removeItemAtPath:roomBubbleTableViewCell.bubbleData.attachment.cacheFilePath error:nil]; [[NSFileManager defaultManager] removeItemAtPath:roomBubbleTableViewCell.bubbleData.attachment.cacheThumbnailPath error:nil]; + + // Cancel and remove the outgoing message + [self.roomDataSource.room cancelSendingOperation:selectedEvent.eventId]; [self.roomDataSource removeEventWithEventId:selectedEvent.eventId]; [self cancelEventSelection];