diff --git a/lib/controllers/ApiController.dart b/lib/controllers/ApiController.dart index b2bccd8..aaa7e0d 100644 --- a/lib/controllers/ApiController.dart +++ b/lib/controllers/ApiController.dart @@ -169,6 +169,9 @@ class ApiController { Future 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); } diff --git a/lib/model/reponses/DiscussionResponse.dart b/lib/model/reponses/DiscussionResponse.dart index f2f12e4..90a282e 100644 --- a/lib/model/reponses/DiscussionResponse.dart +++ b/lib/model/reponses/DiscussionResponse.dart @@ -6,6 +6,11 @@ class DiscussionResponse { List _posts; ResponseContext _context; + DiscussionResponse.accessDenied() { + this._discussion = Discussion.fromJson(null); + this._posts = []; + } + DiscussionResponse.fromJson(Map json) { this._discussion = Discussion.fromJson(json['discussion_common']); this._posts = json['posts'];