taafee-mobile/lib/features/chat/data_layer/model/read_by.dart
2023-10-17 17:22:55 +03:00

36 lines
829 B
Dart

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;
}
}
}