Переглянути джерело

处理聊天偶现崩溃问题

Steven 5 місяців тому
батько
коміт
3862c602b0

+ 8 - 8
KulexiuForStudent/KulexiuForStudent.xcodeproj/project.pbxproj

@@ -7439,7 +7439,7 @@
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = KulexiuForStudent/KulexiuForStudent.entitlements;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1.7.4;
+				CURRENT_PROJECT_VERSION = 1.7.5.2;
 				DEVELOPMENT_TEAM = B2AP53HHTU;
 				ENABLE_BITCODE = NO;
 				ENABLE_MODULE_VERIFIER = YES;
@@ -7496,7 +7496,7 @@
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/SocialLibraries/Sina/SinaSDK",
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/UMSocialSDKPlugin",
 				);
-				MARKETING_VERSION = 1.7.4;
+				MARKETING_VERSION = 1.7.5;
 				MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
 				MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
 				OTHER_LDFLAGS = (
@@ -7626,7 +7626,7 @@
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = KulexiuForStudent/KulexiuForStudent.entitlements;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1.7.4;
+				CURRENT_PROJECT_VERSION = 1.7.5.2;
 				DEVELOPMENT_TEAM = B2AP53HHTU;
 				ENABLE_BITCODE = NO;
 				ENABLE_MODULE_VERIFIER = YES;
@@ -7683,7 +7683,7 @@
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/SocialLibraries/Sina/SinaSDK",
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/UMSocialSDKPlugin",
 				);
-				MARKETING_VERSION = 1.7.4;
+				MARKETING_VERSION = 1.7.5;
 				MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
 				MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
 				OTHER_LDFLAGS = (
@@ -7959,7 +7959,7 @@
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = KulexiuForStudent/KulexiuForStudent.entitlements;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1.7.4;
+				CURRENT_PROJECT_VERSION = 1.7.5.2;
 				DEVELOPMENT_TEAM = B2AP53HHTU;
 				ENABLE_BITCODE = NO;
 				ENABLE_MODULE_VERIFIER = YES;
@@ -8016,7 +8016,7 @@
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/SocialLibraries/Sina/SinaSDK",
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/UMSocialSDKPlugin",
 				);
-				MARKETING_VERSION = 1.7.4;
+				MARKETING_VERSION = 1.7.5;
 				MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
 				MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
 				OTHER_LDFLAGS = (
@@ -8250,7 +8250,7 @@
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = KulexiuForStudent/KulexiuForStudent.entitlements;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1.7.4;
+				CURRENT_PROJECT_VERSION = 1.7.5.2;
 				DEVELOPMENT_TEAM = B2AP53HHTU;
 				ENABLE_BITCODE = NO;
 				ENABLE_MODULE_VERIFIER = YES;
@@ -8307,7 +8307,7 @@
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/SocialLibraries/Sina/SinaSDK",
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/UMSocialSDKPlugin",
 				);
-				MARKETING_VERSION = 1.7.4;
+				MARKETING_VERSION = 1.7.5;
 				MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
 				MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
 				OTHER_LDFLAGS = (

+ 2 - 2
KulexiuForStudent/KulexiuForStudent/Module/Chat/Group/View/GroupSettingBodyView.xib

@@ -303,7 +303,7 @@
                             <nil key="highlightedColor"/>
                         </label>
                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="K7k-ff-Bs3">
-                            <rect key="frame" x="16" y="54" width="398" height="1"/>
+                            <rect key="frame" x="16" y="0.0" width="398" height="1"/>
                             <color key="backgroundColor" red="0.94117647059999998" green="0.94117647059999998" blue="0.94117647059999998" alpha="1" colorSpace="calibratedRGB"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="1" id="CiA-Yu-WAS"/>
@@ -318,9 +318,9 @@
                         <constraint firstItem="wGu-Ji-Izg" firstAttribute="centerY" secondItem="0hZ-Dj-wqy" secondAttribute="centerY" id="Ncj-TG-giW"/>
                         <constraint firstAttribute="height" constant="55" id="OJA-EE-coh"/>
                         <constraint firstItem="jgL-fA-2h0" firstAttribute="centerY" secondItem="0hZ-Dj-wqy" secondAttribute="centerY" id="QO5-DD-RdR"/>
+                        <constraint firstItem="K7k-ff-Bs3" firstAttribute="top" secondItem="0hZ-Dj-wqy" secondAttribute="top" id="Yyy-7u-UsF"/>
                         <constraint firstAttribute="trailing" secondItem="jgL-fA-2h0" secondAttribute="trailing" constant="10" id="b39-Pk-DXM"/>
                         <constraint firstItem="K7k-ff-Bs3" firstAttribute="leading" secondItem="0hZ-Dj-wqy" secondAttribute="leading" constant="16" id="bXz-DV-Cag"/>
-                        <constraint firstAttribute="bottom" secondItem="K7k-ff-Bs3" secondAttribute="bottom" id="uhf-3G-fgK"/>
                     </constraints>
                     <connections>
                         <outletCollection property="gestureRecognizers" destination="bpJ-RX-zB4" appends="YES" id="dVS-cS-Bxl"/>

+ 80 - 30
KulexiuForStudent/Pods/TUIChat/TUIChat/UI_Classic/Chat/TUIBaseMessageController.m

@@ -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];
     }];
 }