|
|
@@ -348,23 +348,39 @@ class KeyboardViewModel : BaseViewModel() {
|
|
|
onSuccess: () -> Unit,
|
|
|
onFail: (String) -> Unit
|
|
|
) {
|
|
|
- val req = SuperReplyReq(
|
|
|
- // 键盘Id
|
|
|
- keyboardId = _currentKeyboardInfo.value?.id ?: "",
|
|
|
- // 人设Id
|
|
|
- characterId = characterId,
|
|
|
- // 用户粘贴板中的内容
|
|
|
- content = _userClipboardData.value ?: ""
|
|
|
- )
|
|
|
- _chatSuperReplyResult.value = ""
|
|
|
- mKeyboardRepository.chatSuperReply(req, onSuccess = {
|
|
|
- // 只有一条数据,直接添加到输入框
|
|
|
- _chatSuperReplyResult.value = it.content
|
|
|
- onSuccess.invoke()
|
|
|
- }, onFail = { errorCode, errorMsg ->
|
|
|
- ErrorHandler.handleError(errorCode, errorMsg)
|
|
|
- onFail.invoke(errorMsg)
|
|
|
- })
|
|
|
+ fun doAction(keyboardId: String) {
|
|
|
+ val req = SuperReplyReq(
|
|
|
+ // 键盘Id
|
|
|
+ keyboardId = keyboardId,
|
|
|
+ // 人设Id
|
|
|
+ characterId = characterId,
|
|
|
+ // 用户粘贴板中的内容
|
|
|
+ content = _userClipboardData.value ?: ""
|
|
|
+ )
|
|
|
+ _chatSuperReplyResult.value = ""
|
|
|
+ mKeyboardRepository.chatSuperReply(req, onSuccess = {
|
|
|
+ // 只有一条数据,直接添加到输入框
|
|
|
+ _chatSuperReplyResult.value = it.content
|
|
|
+ onSuccess.invoke()
|
|
|
+ }, onFail = { errorCode, errorMsg ->
|
|
|
+ ErrorHandler.handleError(errorCode, errorMsg)
|
|
|
+ onFail.invoke(errorMsg)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ var keyboardId = _currentKeyboardInfo.value?.id ?: ""
|
|
|
+ // 如果没有,则重新获取
|
|
|
+ if (keyboardId.isBlank()) {
|
|
|
+ getCurrentKeyboardInfoWithDefault(onSuccess = {
|
|
|
+ keyboardId = it.id ?: ""
|
|
|
+ doAction(keyboardId)
|
|
|
+ }, onFail = { errorCode, errorMsg ->
|
|
|
+ ErrorHandler.handleError(errorCode, errorMsg)
|
|
|
+ onFail.invoke(errorMsg)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ doAction(keyboardId)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -378,24 +394,40 @@ class KeyboardViewModel : BaseViewModel() {
|
|
|
onSuccess: () -> Unit,
|
|
|
onFail: (String) -> Unit
|
|
|
) {
|
|
|
- onStart.invoke()
|
|
|
- _superSpeakChatListResult.value = listOf<String>()
|
|
|
- val req = SuperSpeakReq(
|
|
|
- // 键盘Id
|
|
|
- keyboardId = _currentKeyboardInfo.value?.id ?: "",
|
|
|
- // 人设Id
|
|
|
- characterId = characterId,
|
|
|
- // 用户粘贴板中的内容
|
|
|
- content = _userClipboardData.value ?: ""
|
|
|
- )
|
|
|
- mKeyboardRepository.chatSuperSpeak(req, onSuccess = {
|
|
|
- // 有多条数据,需要跳转列表页面中显示
|
|
|
- _superSpeakChatListResult.value = it.list
|
|
|
- onSuccess.invoke()
|
|
|
- }, onFail = { errorCode, errorMsg ->
|
|
|
- ErrorHandler.handleError(errorCode, errorMsg)
|
|
|
- onFail.invoke(errorMsg)
|
|
|
- })
|
|
|
+ fun doAction(keyboardId: String) {
|
|
|
+ onStart.invoke()
|
|
|
+ _superSpeakChatListResult.value = listOf<String>()
|
|
|
+ val req = SuperSpeakReq(
|
|
|
+ // 键盘Id
|
|
|
+ keyboardId = keyboardId,
|
|
|
+ // 人设Id
|
|
|
+ characterId = characterId,
|
|
|
+ // 用户粘贴板中的内容
|
|
|
+ content = _userClipboardData.value ?: ""
|
|
|
+ )
|
|
|
+ mKeyboardRepository.chatSuperSpeak(req, onSuccess = {
|
|
|
+ // 有多条数据,需要跳转列表页面中显示
|
|
|
+ _superSpeakChatListResult.value = it.list
|
|
|
+ onSuccess.invoke()
|
|
|
+ }, onFail = { errorCode, errorMsg ->
|
|
|
+ ErrorHandler.handleError(errorCode, errorMsg)
|
|
|
+ onFail.invoke(errorMsg)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ var keyboardId = _currentKeyboardInfo.value?.id ?: ""
|
|
|
+ // 如果没有,则重新获取
|
|
|
+ if (keyboardId.isBlank()) {
|
|
|
+ getCurrentKeyboardInfoWithDefault(onSuccess = {
|
|
|
+ keyboardId = it.id ?: ""
|
|
|
+ doAction(keyboardId)
|
|
|
+ }, onFail = { errorCode, errorMsg ->
|
|
|
+ ErrorHandler.handleError(errorCode, errorMsg)
|
|
|
+ onFail.invoke(errorMsg)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ doAction(keyboardId)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|