parseTitleInfo method

BotSubsessionTitleInfo parseTitleInfo(
  1. V2NIMTopic? topic
)

Implementation

BotSubsessionTitleInfo parseTitleInfo(V2NIMTopic? topic) {
  if (topic == null) {
    return const BotSubsessionTitleInfo(title: null, userRenamed: false);
  }
  final serverExtension = topic.serverExtension;
  if (serverExtension?.isNotEmpty == true) {
    try {
      final json = jsonDecode(serverExtension!) as Map<String, dynamic>;
      final title = json['title'] as String?;
      final userRenamed = json['userRenamed'] == true;
      return BotSubsessionTitleInfo(
        title: title?.trim().isNotEmpty == true ? title!.trim() : null,
        userRenamed: userRenamed,
      );
    } catch (_) {}
  }
  return BotSubsessionTitleInfo(
    title: topic.topicName?.trim().isNotEmpty == true
        ? topic.topicName!.trim()
        : null,
    userRenamed: false,
  );
}