diff --git a/Riot/Modules/MatrixKit/Models/Room/MXKRoomDataSource.h b/Riot/Modules/MatrixKit/Models/Room/MXKRoomDataSource.h index 6bb9e5042..bc0f4e6bb 100644 --- a/Riot/Modules/MatrixKit/Models/Room/MXKRoomDataSource.h +++ b/Riot/Modules/MatrixKit/Models/Room/MXKRoomDataSource.h @@ -452,18 +452,16 @@ extern NSString *const kMXKRoomDataSourceTimelineErrorErrorKey; While sending, a fake event will be echoed in the messages list. Once complete, this local echo will be replaced by the event saved by the homeserver. - @param eventIdToReply the id of event to reply. + @param eventToReply the event to reply. @param text the text to send. - @param actualData the data source actually. It's use to retrieve event to reply. @param success A block object called when the operation succeeds. It returns the event id of the event generated on the homeserver @param failure A block object called when the operation fails. */ -- (void)sendReplyToEventWithId:(NSString*)eventIdToReply - withTextMessage:(NSString *)text - actualRoomDataSource:(MXKRoomDataSource *)actualData - success:(void (^)(NSString *))success - failure:(void (^)(NSError *))failure; +- (void)sendReplyToEvent:(MXEvent*)eventToReply + withTextMessage:(NSString *)text + success:(void (^)(NSString *))success + failure:(void (^)(NSError *))failure; /** Indicates if replying to the provided event is supported. @@ -797,18 +795,16 @@ extern NSString *const kMXKRoomDataSourceTimelineErrorErrorKey; /** Replace a text in an event. - @param eventId The eventId of event to replace. + @param event The event to replace. @param text The new message text. - @param actualData the data source actually. It's use to retrieve event to replace. @param success A block object called when the operation succeeds. It returns the event id of the event generated on the homeserver. @param failure A block object called when the operation fails. */ -- (void)replaceTextMessageForEventWithId:(NSString *)eventId - withTextMessage:(NSString *)text - actualRoomDataSource:(MXKRoomDataSource *)actualData - success:(void (^)(NSString *eventId))success - failure:(void (^)(NSError *error))failure; +- (void)replaceTextMessageForEvent:(MXEvent *)event + withTextMessage:(NSString *)text + success:(void (^)(NSString *eventId))success + failure:(void (^)(NSError *error))failure; /** diff --git a/Riot/Modules/MatrixKit/Models/Room/MXKRoomDataSource.m b/Riot/Modules/MatrixKit/Models/Room/MXKRoomDataSource.m index 49e62b8a0..3e4d7e5d6 100644 --- a/Riot/Modules/MatrixKit/Models/Room/MXKRoomDataSource.m +++ b/Riot/Modules/MatrixKit/Models/Room/MXKRoomDataSource.m @@ -1870,14 +1870,11 @@ typedef NS_ENUM (NSUInteger, MXKRoomDataSourceError) { } } -- (void)sendReplyToEventWithId:(NSString*)eventIdToReply - withTextMessage:(NSString *)text - actualRoomDataSource:(MXKRoomDataSource *)actualData - success:(void (^)(NSString *))success - failure:(void (^)(NSError *))failure +- (void)sendReplyToEvent:(MXEvent*)eventToReply + withTextMessage:(NSString *)text + success:(void (^)(NSString *))success + failure:(void (^)(NSError *))failure { - MXEvent *eventToReply = [actualData eventWithEventId:eventIdToReply]; - __block MXEvent *localEchoEvent = nil; NSString *sanitizedText = [self sanitizedMessageText:text]; @@ -4285,14 +4282,11 @@ typedef NS_ENUM (NSUInteger, MXKRoomDataSourceError) { return hasChanged; } -- (void)replaceTextMessageForEventWithId:(NSString*)eventId - withTextMessage:(NSString *)text - actualRoomDataSource:(MXKRoomDataSource *)actualData - success:(void (^)(NSString *))success - failure:(void (^)(NSError *))failure +- (void)replaceTextMessageForEvent:(MXEvent*)event + withTextMessage:(NSString *)text + success:(void (^)(NSString *))success + failure:(void (^)(NSError *))failure { - MXEvent *event = [actualData eventWithEventId:eventId]; - NSString *sanitizedText = [self sanitizedMessageText:text]; NSString *formattedText = [self htmlMessageFromSanitizedText:sanitizedText]; diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 2d5cd5aa1..1ab7770ab 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -1254,23 +1254,25 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; - (void)sendTextMessage:(NSString*)msgTxt { + // The event modified is always fetch from the actual data source + MXEvent *eventModified = [self.roomDataSource eventWithEventId:customizedRoomDataSource.selectedEventId]; // If the event occur on timeline not live, use the live data source to resolve event BOOL isLive = self.roomDataSource.isLive; if (isLive == NO) { [self setupRoomDataSourceLive]; } - MXKRoomDataSource *roomDataSource = isLive ? self.roomDataSource : self.roomDataSourceLive; + MXKRoomDataSource *roomDataSourceNotified = isLive ? self.roomDataSource : self.roomDataSourceLive; if (self.inputToolBarSendMode == RoomInputToolbarViewSendModeReply && customizedRoomDataSource.selectedEventId) { - [roomDataSource sendReplyToEventWithId:customizedRoomDataSource.selectedEventId withTextMessage:msgTxt actualRoomDataSource:self.roomDataSource success:nil failure:^(NSError *error) { + [roomDataSourceNotified sendReplyToEvent:eventModified withTextMessage:msgTxt success:nil failure:^(NSError *error) { // Just log the error. The message will be displayed in red in the room history MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed."); }]; } else if (self.inputToolBarSendMode == RoomInputToolbarViewSendModeEdit && customizedRoomDataSource.selectedEventId) { - [roomDataSource replaceTextMessageForEventWithId:customizedRoomDataSource.selectedEventId withTextMessage:msgTxt actualRoomDataSource:self.roomDataSource success:nil failure:^(NSError *error) { + [roomDataSourceNotified replaceTextMessageForEvent:eventModified withTextMessage:msgTxt success:nil failure:^(NSError *error) { // Just log the error. The message will be displayed in red MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed."); }]; @@ -1278,7 +1280,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; else { // Let the datasource send it and manage the local echo - [roomDataSource sendTextMessage:msgTxt success:nil failure:^(NSError *error) + [roomDataSourceNotified sendTextMessage:msgTxt success:nil failure:^(NSError *error) { // Just log the error. The message will be displayed in red in the room history MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed.");