Skip to content

Commit

Permalink
fix: closes #208
Browse files Browse the repository at this point in the history
  • Loading branch information
lucien144 committed May 1, 2021
1 parent 38b2afc commit 5724a97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/controllers/ApiController.dart
Expand Up @@ -169,6 +169,9 @@ class ApiController {

Future<DiscussionResponse> loadDiscussion(int id, {int lastId, String user}) async {
var response = await provider.fetchDiscussion(id, lastId: lastId == null ? null : lastId + 1, user: user);
if (response.statusCode == 400) {
return DiscussionResponse.accessDenied();
}
return DiscussionResponse.fromJson(response.data);
}

Expand Down
5 changes: 5 additions & 0 deletions lib/model/reponses/DiscussionResponse.dart
Expand Up @@ -6,6 +6,11 @@ class DiscussionResponse {
List _posts;
ResponseContext _context;

DiscussionResponse.accessDenied() {
this._discussion = Discussion.fromJson(null);
this._posts = [];
}

DiscussionResponse.fromJson(Map<String, dynamic> json) {
this._discussion = Discussion.fromJson(json['discussion_common']);
this._posts = json['posts'];
Expand Down

0 comments on commit 5724a97

Please sign in to comment.