This commit is contained in:
parent
d9b65c0e7e
commit
62cb78167d
|
|
@ -144,10 +144,6 @@ public class CallBackResolution {
|
|||
CallBackUtil.callBackGroupInfo(groupId, tempTxt, groupNo, groupCount);
|
||||
Timber.tag(TAG).d( "at_OEM_AT_cb group info groupId: " + groupId + ", groupNo: " + groupNo+", groupCount: " +groupCount);
|
||||
if (1 == groupNo) groupInfos.clear();
|
||||
if (groupInfos.size() >= MAX_GROUP_INFOS) {
|
||||
Iterator<String> it = groupInfos.keySet().iterator();
|
||||
if (it.hasNext()) { it.next(); it.remove(); }
|
||||
}
|
||||
GroupInfoDto groupInfo = new GroupInfoDto(groupId, tempTxt, groupNo, groupCount);
|
||||
groupInfos.put(groupId, groupInfo);
|
||||
}
|
||||
|
|
@ -178,10 +174,6 @@ public class CallBackResolution {
|
|||
String tempTxt = unicodeToString(groupMemberName.toString());
|
||||
GroupMemberInfoDto infoDto = new GroupMemberInfoDto(memberId, tempTxt, status, memberNo, haveVideo);
|
||||
if (memberNo == 1) memberInfoDtos.clear();
|
||||
if (memberInfoDtos.size() >= MAX_GROUP_MEMBERS) {
|
||||
Iterator<String> it = memberInfoDtos.keySet().iterator();
|
||||
if (it.hasNext()) { it.next(); it.remove(); }
|
||||
}
|
||||
memberInfoDtos.put(memberId, infoDto);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -280,15 +280,14 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
|
|||
}
|
||||
|
||||
private fun finalizeAiMessage(messageId: String) {
|
||||
flushStreamingMessage(messageId)
|
||||
val finalResidue = chunkBuffer.remove(messageId)?.toString() ?: ""
|
||||
_messages.value = _messages.value.map { msg ->
|
||||
if (msg.id == messageId) {
|
||||
val finalContent = _streamingContent.value[messageId] ?: msg.content
|
||||
val finalContent = (_streamingContent.value[messageId] ?: msg.content) + finalResidue
|
||||
_streamingContent.update { it - messageId }
|
||||
msg.copy(content = finalContent, isStreaming = false)
|
||||
} else msg
|
||||
}
|
||||
chunkBuffer.remove(messageId)
|
||||
lastFlushAt.remove(messageId)
|
||||
saveCacheToLocal()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,6 +162,18 @@ fun ChatArea(
|
|||
|
||||
@Composable
|
||||
fun MarkwonRenderer(markdown: String, modifier: Modifier) {
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
val markwon = remember(context) {
|
||||
io.noties.markwon.Markwon.builder(context)
|
||||
.usePlugin(io.noties.markwon.core.CorePlugin.create())
|
||||
.usePlugin(io.noties.markwon.ext.tables.TablePlugin.create(context))
|
||||
.usePlugin(io.noties.markwon.html.HtmlPlugin.create())
|
||||
.usePlugin(io.noties.markwon.linkify.LinkifyPlugin.create())
|
||||
.usePlugin(io.noties.markwon.ext.strikethrough.StrikethroughPlugin.create())
|
||||
.usePlugin(io.noties.markwon.ext.tasklist.TaskListPlugin.create(context))
|
||||
.build()
|
||||
}
|
||||
|
||||
androidx.compose.ui.viewinterop.AndroidView(
|
||||
factory = { ctx ->
|
||||
val textView = SafeSelectableTextView(ctx).apply {
|
||||
|
|
@ -173,15 +185,14 @@ fun MarkwonRenderer(markdown: String, modifier: Modifier) {
|
|||
setPadding(0, 0, 0, 0)
|
||||
}
|
||||
|
||||
val markwon = MarkwonHolder.get(ctx)
|
||||
textView.tag = markwon
|
||||
textView
|
||||
},
|
||||
update = { view ->
|
||||
try {
|
||||
val markwon = view.tag as? io.noties.markwon.Markwon
|
||||
if (markwon != null) {
|
||||
markwon.setMarkdown(view, markdown)
|
||||
val currentMarkwon = view.tag as? io.noties.markwon.Markwon
|
||||
if (currentMarkwon != null) {
|
||||
currentMarkwon.setMarkdown(view, markdown)
|
||||
} else {
|
||||
view.text = markdown
|
||||
}
|
||||
|
|
@ -192,26 +203,3 @@ fun MarkwonRenderer(markdown: String, modifier: Modifier) {
|
|||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
||||
private object MarkwonHolder {
|
||||
@Volatile
|
||||
private var instance: io.noties.markwon.Markwon? = null
|
||||
|
||||
fun get(context: android.content.Context): io.noties.markwon.Markwon {
|
||||
instance?.let { return it }
|
||||
return synchronized(this) {
|
||||
instance ?: build(context.applicationContext).also { instance = it }
|
||||
}
|
||||
}
|
||||
|
||||
private fun build(context: android.content.Context): io.noties.markwon.Markwon {
|
||||
return io.noties.markwon.Markwon.builder(context)
|
||||
.usePlugin(io.noties.markwon.core.CorePlugin.create())
|
||||
.usePlugin(io.noties.markwon.ext.tables.TablePlugin.create(context))
|
||||
.usePlugin(io.noties.markwon.html.HtmlPlugin.create())
|
||||
.usePlugin(io.noties.markwon.linkify.LinkifyPlugin.create())
|
||||
.usePlugin(io.noties.markwon.ext.strikethrough.StrikethroughPlugin.create())
|
||||
.usePlugin(io.noties.markwon.ext.tasklist.TaskListPlugin.create(context))
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue