修复 KBChatPanel 发送内容校验
This commit is contained in:
@@ -93,13 +93,25 @@ static const NSUInteger kKBChatMessageLimit = 6;
|
||||
NSString *trim =
|
||||
[rawText stringByTrimmingCharactersInSet:
|
||||
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
NSString *textToClear = rawText;
|
||||
if (trim.length == 0) {
|
||||
// 兼容「先输入再打开聊天面板」场景:
|
||||
// 此时新增文本为空,但当前输入框已有可发送内容,应该允许直接发送。
|
||||
NSString *fullTrim =
|
||||
[fullText stringByTrimmingCharactersInSet:
|
||||
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (fullTrim.length > 0) {
|
||||
trim = fullTrim;
|
||||
textToClear = fullText;
|
||||
}
|
||||
}
|
||||
if (trim.length == 0) {
|
||||
[KBHUD showInfo:KBLocalized(@"请输入内容")];
|
||||
return;
|
||||
}
|
||||
[self kb_sendChatText:trim];
|
||||
// 只清除新增的文本,保留基线文本
|
||||
[self kb_clearHostInputForText:rawText];
|
||||
// 默认只清新增文本;若命中兜底则清当前全文,避免“已发送但输入框残留”。
|
||||
[self kb_clearHostInputForText:textToClear];
|
||||
}
|
||||
|
||||
- (void)kb_sendChatText:(NSString *)text {
|
||||
|
||||
Reference in New Issue
Block a user