createThreadIfNotExits method
Implementation
Future<bool> createThreadIfNotExits({String? threadName}) async {
if (thread != null) {
return true;
}
String name = threadName ?? model?.message.showInfo() ?? '';
if (name.length > 32) {
name = '${name.substring(0, 29)}...';
}
try {
ChatThread createdThread = await ChatUIKit.instance.createChatThread(
threadName: name,
messageId: model?.message.msgId ?? '',
parentId: model?.message.conversationId ?? '',
);
model = model?.copyWith(thread: createdThread);
thread = createdThread;
loadFinished = true;
hasPermission = true;
insertCreateMessage();
return true;
} catch (e) {
chatPrint('create thread error: $e');
}
return false;
}