class ReadBy {
  int id, messageId;
  List<int> ids;
  ReadBy({required this.id, required this.ids, required this.messageId});

  factory ReadBy.fromJson(Map<String, dynamic> jsonMap) => ReadBy(
        id: jsonMap['id'],
        messageId: jsonMap['messageId'],
        ids: parsedIdsList(jsonMap['ids']),
      );

  static List<int> parsedIdsList(String idsString) {
    List<int> parsedList = [];
    String temp = '';
    for (int i = 0; i < idsString.length; i++) {
      if (idsString[i] == ',' && temp != '') {
        parsedList.add(int.parse(temp));
        temp = '';
      } else {
        if (idsString[i] != ',') {
          temp = temp + idsString[i];
        }
      }
    }
    return parsedList;
  }

  bool isReaded() {
    if (ids.length > 1) {
      return true;
    } else {
      return false;
    }
  }
}
