Skip to content

Commit

Permalink
fix api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
avdosev committed Apr 23, 2021
1 parent 689e652 commit c3ae85a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/habr/json_parsing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool _commentIsBanned(Map<String, dynamic> json) {

Comments parseCommentsFromJson(Map<String, dynamic> data) {
return Comments(
threads: (data['threads'] as List).cast<int>(),
threads: (data['threads'] as List).cast<String>().map(int.parse).toList(),
comments: (data['comments'] as Map<String, dynamic>)
.map<int, Comment>((key, value) {
return MapEntry(int.parse(key), parseCommentFromJson(value));
Expand All @@ -36,15 +36,15 @@ Comments parseCommentsFromJson(Map<String, dynamic> data) {
Comment parseCommentFromJson(Map<String, dynamic> json) {
final isBanned = _commentIsBanned(json);
return Comment(
id: json['id'],
parentId: json['parentId'],
id: int.parse(json['id']),
parentId: json['parentId'] == null ? null : int.parse(json['parentId']),
level: json['level'],
banned: isBanned,
timePublished: isBanned ? null : DateTime.parse(json['timePublished']),
timeChanged: json['timeChanged'] == null
? null
: DateTime.parse(json['timeChanged']),
children: (json['children'] as List).cast<int>(),
children: (json['children'] as List).cast<String>().map(int.parse).toList(),
author: isBanned ? null : parseAuthorFromJson(json['author']),
message: json['message']);
}
Expand Down

0 comments on commit c3ae85a

Please sign in to comment.