|  | @@ -283,49 +283,93 @@
 | 
	
		
			
				|  |  |                           toConversation:self.conversationData
 | 
	
		
			
				|  |  |                            willSendBlock:^(BOOL isReSend, TUIMessageCellData *_Nonnull dateUIMsg) {
 | 
	
		
			
				|  |  |          @strongify(self);
 | 
	
		
			
				|  |  | -        [self scrollToBottom:YES];
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        int delay = 1;
 | 
	
		
			
				|  |  | -        if ([cellData isKindOfClass:[TUIImageMessageCellData class]]) {
 | 
	
		
			
				|  |  | -            delay = 0;
 | 
	
		
			
				|  |  | +        if ([cellData isKindOfClass:[TUIVideoMessageCellData class]]) {
 | 
	
		
			
				|  |  | +            dispatch_async(dispatch_get_main_queue(), ^{
 | 
	
		
			
				|  |  | +                [self scrollToBottom:YES];
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            [self scrollToBottom:YES];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        @weakify(self);
 | 
	
		
			
				|  |  | -        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
 | 
	
		
			
				|  |  | -            @strongify(self);
 | 
	
		
			
				|  |  | -            if (cellData.status == Msg_Status_Sending) {
 | 
	
		
			
				|  |  | -                [self changeMsg:cellData status:Msg_Status_Sending_2];
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | +        [self setUIMessageStatus:cellData status:Msg_Status_Sending_2];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |                                SuccBlock:^{
 | 
	
		
			
				|  |  |          @strongify(self);
 | 
	
		
			
				|  |  |          [self reloadUIMessage:cellData];
 | 
	
		
			
				|  |  | -        [self changeMsg:cellData status:Msg_Status_Succ];
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +        [self setUIMessageStatus:cellData status:Msg_Status_Succ];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          NSDictionary *param = @{
 | 
	
		
			
				|  |  |              TUICore_TUIChatNotify_SendMessageSubKey_Code : @0,
 | 
	
		
			
				|  |  |              TUICore_TUIChatNotify_SendMessageSubKey_Desc : @"",
 | 
	
		
			
				|  |  |              TUICore_TUIChatNotify_SendMessageSubKey_Message : cellData.innerMessage
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  | -        [TUICore notifyEvent:TUICore_TUIChatNotify subKey:TUICore_TUIChatNotify_SendMessageSubKey object:self param:nil];
 | 
	
		
			
				|  |  | +        [TUICore notifyEvent:TUICore_TUIChatNotify subKey:TUICore_TUIChatNotify_SendMessageSubKey object:self param:param];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |                                FailBlock:^(int code, NSString *desc) {
 | 
	
		
			
				|  |  |          @strongify(self);
 | 
	
		
			
				|  |  | -        if (self.isMsgNeedReadReceipt && code == ERR_SDK_INTERFACE_NOT_SUPPORT) {
 | 
	
		
			
				|  |  | -            NSString *msg = [NSString stringWithFormat:@"%@%@", TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceMessageRead),
 | 
	
		
			
				|  |  | -                             TUIKitLocalizableString(TUIKitErrorUnsupporInterfaceSuffix)];
 | 
	
		
			
				|  |  | -            [TUITool makeToast:msg];
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            [TUITool makeToastError:code msg:desc];
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        [self changeMsg:cellData status:Msg_Status_Fail];
 | 
	
		
			
				|  |  | +        [self reloadUIMessage:cellData];
 | 
	
		
			
				|  |  | +        [self setUIMessageStatus:cellData status:Msg_Status_Fail];
 | 
	
		
			
				|  |  | +        [self makeSendErrorHud:code desc:desc];
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  | -        NSDictionary *param = @{TUICore_TUIChatNotify_SendMessageSubKey_Code : @(code), TUICore_TUIChatNotify_SendMessageSubKey_Desc : desc};
 | 
	
		
			
				|  |  | +        NSDictionary *param = @{TUICore_TUIChatNotify_SendMessageSubKey_Code : @(code),
 | 
	
		
			
				|  |  | +                                TUICore_TUIChatNotify_SendMessageSubKey_Desc : desc};
 | 
	
		
			
				|  |  |          [TUICore notifyEvent:TUICore_TUIChatNotify subKey:TUICore_TUIChatNotify_SendMessageSubKey object:self param:param];
 | 
	
		
			
				|  |  |      }];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +- (void)setUIMessageStatus:(TUIMessageCellData *)cellData status:(TMsgStatus)status {
 | 
	
		
			
				|  |  | +    switch (status) {
 | 
	
		
			
				|  |  | +        case Msg_Status_Init:
 | 
	
		
			
				|  |  | +        case Msg_Status_Succ:
 | 
	
		
			
				|  |  | +        case Msg_Status_Fail:
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                [self changeMsg:cellData status:status];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            break;
 | 
	
		
			
				|  |  | +        case Msg_Status_Sending:
 | 
	
		
			
				|  |  | +        case Msg_Status_Sending_2:
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                int delay = 1;
 | 
	
		
			
				|  |  | +                if ([cellData isKindOfClass:[TUIImageMessageCellData class]] ||
 | 
	
		
			
				|  |  | +                    [cellData isKindOfClass:[TUIVideoMessageCellData class]]) {
 | 
	
		
			
				|  |  | +                    delay = 0;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (0 == delay) {
 | 
	
		
			
				|  |  | +                    [self changeMsg:cellData status:Msg_Status_Sending_2];
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
 | 
	
		
			
				|  |  | +                        if (cellData.innerMessage.status == V2TIM_MSG_STATUS_SENDING) {
 | 
	
		
			
				|  |  | +                            [self changeMsg:cellData status:Msg_Status_Sending_2];
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            break;
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +        default:
 | 
	
		
			
				|  |  | +            break;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)makeSendErrorHud:(int)code desc:(NSString *)desc  {
 | 
	
		
			
				|  |  | +    // The text or image msg is sensitive, the cell height may change.
 | 
	
		
			
				|  |  | +    if (code == 80001 || code == 80004) {
 | 
	
		
			
				|  |  | +        [self scrollToBottom:YES];
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    NSString *errorMsg = @"";
 | 
	
		
			
				|  |  | +    if (self.isMsgNeedReadReceipt && code == ERR_SDK_INTERFACE_NOT_SUPPORT) {
 | 
	
		
			
				|  |  | +        errorMsg = [NSString stringWithFormat:@"%@%@", TUIKitLocalizableString(TUIKitErrorUnsupportIntefaceMessageRead),
 | 
	
		
			
				|  |  | +                                         TUIKitLocalizableString(TUIKitErrorUnsupporInterfaceSuffix)];
 | 
	
		
			
				|  |  | +    } else {
 | 
	
		
			
				|  |  | +        errorMsg = [TUITool convertIMError:code msg:desc];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    errorMsg = @"消息发送失败";
 | 
	
		
			
				|  |  | +    UIAlertController *ac = [UIAlertController alertControllerWithTitle:errorMsg message:nil preferredStyle:UIAlertControllerStyleAlert];
 | 
	
		
			
				|  |  | +    [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(Confirm) style:UIAlertActionStyleDefault handler:nil]];
 | 
	
		
			
				|  |  | +    [self presentViewController:ac animated:YES completion:nil];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  - (void)sendMessage:(V2TIMMessage *)message {
 | 
	
		
			
				|  |  |      [self sendMessage:message placeHolderCellData:nil];
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -348,12 +392,18 @@
 | 
	
		
			
				|  |  |  - (void)reloadUIMessage:(TUIMessageCellData *)msg {
 | 
	
		
			
				|  |  |      // innerMessage maybe changed, reload it
 | 
	
		
			
				|  |  |      NSInteger index = [self.messageDataProvider.uiMsgs indexOfObject:msg];
 | 
	
		
			
				|  |  | -    TUIMessageCellData *newData = [self.messageDataProvider transUIMsgFromIMMsg:@[ msg.innerMessage ]].lastObject;
 | 
	
		
			
				|  |  | -    __weak typeof(self) weakSelf = self;
 | 
	
		
			
				|  |  | -    [self.messageDataProvider preProcessMessage:@[ newData ]
 | 
	
		
			
				|  |  | +    NSMutableArray *newUIMsgs = [self.messageDataProvider transUIMsgFromIMMsg:@[ msg.innerMessage ]];
 | 
	
		
			
				|  |  | +    if (newUIMsgs.count == 0) {
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    TUIMessageCellData *newUIMsg = newUIMsgs.firstObject;
 | 
	
		
			
				|  |  | +    @weakify(self)
 | 
	
		
			
				|  |  | +    [self.messageDataProvider preProcessMessage:@[ newUIMsg ]
 | 
	
		
			
				|  |  |                                         callback:^{
 | 
	
		
			
				|  |  | -        [weakSelf.messageDataProvider replaceUIMsg:newData atIndex:index];
 | 
	
		
			
				|  |  | -        [weakSelf.tableView reloadData];
 | 
	
		
			
				|  |  | +        @strongify(self)
 | 
	
		
			
				|  |  | +        [self.messageDataProvider replaceUIMsg:newUIMsg atIndex:index];
 | 
	
		
			
				|  |  | +        [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]]
 | 
	
		
			
				|  |  | +                              withRowAnimation:UITableViewRowAnimationNone];
 | 
	
		
			
				|  |  |      }];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |