/// 枚举定义：所有的会话类型分组，用于一级消息分类
enum ConversationType {
  noFriend, // 陌生人消息
  system, //系统消息
  newFoucs, //新的关注
  interaction, //互动
  order, //订单类通知消息
  groupNotify, //群通知
}

extension ConversationTypeExtension on ConversationType {
  String get name {
    switch (this) {
      case ConversationType.noFriend:
        return 'noFriend';
      case ConversationType.system:
        return 'system';
      case ConversationType.newFoucs:
        return 'newFoucs';
      case ConversationType.interaction:
        return 'interaction';
      case ConversationType.order:
        return 'order';
      case ConversationType.groupNotify:
        return 'groupNotify';
    }
  }
}

conversationTypeFromString(String? type) {
  if (type == null) return null;

  if (type.contains('noFriend')) {
    return ConversationType.noFriend.name;
  } else if (type.contains('system')) {
    return ConversationType.system.name;
  } else if (type.contains('newFoucs')) {
    return ConversationType.newFoucs.name;
  } else if (type.contains('interaction')) {
    return ConversationType.interaction.name;
  } else if (type.contains('order')) {
    return ConversationType.order.name;
  } else if (type.contains('groupNotify')) {
    return ConversationType.groupNotify.name;
  }

  return null;
}
