{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-app-ios/pulls/comments/54819124","id":54819124,"diff_hunk":"@@ -283,38 +284,60 @@ class DiscussionResponsesViewController: UIViewController, UITableViewDataSource\n         }\n     }\n     \n-    private func initializePaginator() {\n-        \n+    private func loadResponses() {\n         if let thread = thread {\n-            postFollowing = thread.following\n-            \n-            let paginator = WrappedPaginator(networkManager: self.environment.networkManager) { page in\n-                return DiscussionAPI.getResponses(thread.threadID, threadType: thread.type, pageNumber: page)\n+            if !isAnsweredResponsesLoaded &&  thread.type == .Question {\n+                // load answered responses\n+                loadAnsweredResponses()\n+            }\n+            else {\n+                loadAllResponses()\n             }\n-            \n-            paginationController = TablePaginationController (paginator: paginator, tableView: self.tableView)\n-            \n-            loadEndorsedResponses()\n-            loadResponses()\n         }\n     }\n     \n-    private func loadEndorsedResponses() {\n-        if let thread = thread {\n-            // its assumption always there shoud be 1 page for endorsed responses\n-            let apiRequest = DiscussionAPI.getEndorsedResponses(thread.threadID, threadType: .Question)\n-            \n-            self.environment.networkManager.taskForRequest(apiRequest) {[weak self] result in\n-                if let responses = result.data {\n-                    self?.loadController?.state = .Loaded\n-                    self?.responsesDataController.endorsedResponses = responses\n-                    self?.tableView.reloadData()\n-                }\n-            }\n+    private func loadAnsweredResponses() {\n+        \n+        guard let thread = thread else { return }\n+        \n+        postFollowing = thread.following\n+        \n+        let paginator = WrappedPaginator(networkManager: self.environment.networkManager) { page in\n+            return DiscussionAPI.getResponses(thread.threadID, threadType: thread.type, endorsedOnly: true, pageNumber: page)\n         }\n+        \n+        paginationController = TablePaginationController (paginator: paginator, tableView: self.tableView)\n+        \n+        paginationController?.stream.listen(self, success:\n+            { [weak self] responses in\n+                self?.loadController?.state = .Loaded\n+                self?.responsesDataController.endorsedResponses = responses\n+                self?.tableView.reloadData()\n+                \n+                guard let hasMore = self?.paginationController?.hasNext where !hasMore else { return }\n+                \n+                // load unanswered responses\n+                self?.isAnsweredResponsesLoaded = true\n+                self?.loadAllResponses()\n+                \n+            }, failure: { [weak self] (error) -> Void in\n+                self?.loadController?.state = LoadState.failed(error)\n+                \n+            })\n+        \n+        paginationController?.loadMore()\n     }\n     \n-    private func loadResponses() {\n+    private func loadAllResponses() {","path":"Source/DiscussionResponsesViewController.swift","position":87,"original_position":87,"commit_id":"3349b518c655842d051ec32147b9bde056225aff","original_commit_id":"3349b518c655842d051ec32147b9bde056225aff","user":{"login":"aleffert","id":114396,"avatar_url":"https://avatars.githubusercontent.com/u/114396?v=3","gravatar_id":"","url":"https://api.github.com/users/aleffert","html_url":"https://github.com/aleffert","followers_url":"https://api.github.com/users/aleffert/followers","following_url":"https://api.github.com/users/aleffert/following{/other_user}","gists_url":"https://api.github.com/users/aleffert/gists{/gist_id}","starred_url":"https://api.github.com/users/aleffert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aleffert/subscriptions","organizations_url":"https://api.github.com/users/aleffert/orgs","repos_url":"https://api.github.com/users/aleffert/repos","events_url":"https://api.github.com/users/aleffert/events{/privacy}","received_events_url":"https://api.github.com/users/aleffert/received_events","type":"User","site_admin":false},"body":"``allResponses`` doesn't seem like a good name, since it's not *all* responses - only unanswered ones","created_at":"2016-03-03T00:40:37Z","updated_at":"2016-03-03T00:40:37Z","html_url":"https://github.com/edx/edx-app-ios/pull/677#discussion_r54819124","pull_request_url":"https://api.github.com/repos/edx/edx-app-ios/pulls/677","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-app-ios/pulls/comments/54819124"},"html":{"href":"https://github.com/edx/edx-app-ios/pull/677#discussion_r54819124"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-app-ios/pulls/677"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-app-ios/pulls/677","id":61382357,"html_url":"https://github.com/edx/edx-app-ios/pull/677","diff_url":"https://github.com/edx/edx-app-ios/pull/677.diff","patch_url":"https://github.com/edx/edx-app-ios/pull/677.patch","issue_url":"https://api.github.com/repos/edx/edx-app-ios/issues/677","number":677,"state":"open","locked":false,"title":"pagination implemented on answered responses.","user":{"login":"saeedbashir","id":5606473,"avatar_url":"https://avatars.githubusercontent.com/u/5606473?v=3","gravatar_id":"","url":"https://api.github.com/users/saeedbashir","html_url":"https://github.com/saeedbashir","followers_url":"https://api.github.com/users/saeedbashir/followers","following_url":"https://api.github.com/users/saeedbashir/following{/other_user}","gists_url":"https://api.github.com/users/saeedbashir/gists{/gist_id}","starred_url":"https://api.github.com/users/saeedbashir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saeedbashir/subscriptions","organizations_url":"https://api.github.com/users/saeedbashir/orgs","repos_url":"https://api.github.com/users/saeedbashir/repos","events_url":"https://api.github.com/users/saeedbashir/events{/privacy}","received_events_url":"https://api.github.com/users/saeedbashir/received_events","type":"User","site_admin":false},"body":"https://openedx.atlassian.net/browse/MA-2098","created_at":"2016-03-02T10:52:31Z","updated_at":"2016-03-03T00:40:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6fcd8009ce19d37da9e5ade94efeae4cc022227","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-app-ios/pulls/677/commits","review_comments_url":"https://api.github.com/repos/edx/edx-app-ios/pulls/677/comments","review_comment_url":"https://api.github.com/repos/edx/edx-app-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-app-ios/issues/677/comments","statuses_url":"https://api.github.com/repos/edx/edx-app-ios/statuses/3349b518c655842d051ec32147b9bde056225aff","head":{"label":"edx:saeed/MA-2098","ref":"saeed/MA-2098","sha":"3349b518c655842d051ec32147b9bde056225aff","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":29251733,"name":"edx-app-ios","full_name":"edx/edx-app-ios","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-app-ios","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-app-ios","forks_url":"https://api.github.com/repos/edx/edx-app-ios/forks","keys_url":"https://api.github.com/repos/edx/edx-app-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-app-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-app-ios/teams","hooks_url":"https://api.github.com/repos/edx/edx-app-ios/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-app-ios/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-app-ios/events","assignees_url":"https://api.github.com/repos/edx/edx-app-ios/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-app-ios/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-app-ios/tags","blobs_url":"https://api.github.com/repos/edx/edx-app-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-app-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-app-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-app-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-app-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-app-ios/languages","stargazers_url":"https://api.github.com/repos/edx/edx-app-ios/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-app-ios/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-app-ios/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-app-ios/subscription","commits_url":"https://api.github.com/repos/edx/edx-app-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-app-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-app-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-app-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-app-ios/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-app-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-app-ios/merges","archive_url":"https://api.github.com/repos/edx/edx-app-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-app-ios/downloads","issues_url":"https://api.github.com/repos/edx/edx-app-ios/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-app-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-app-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-app-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-app-ios/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-app-ios/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-app-ios/deployments","created_at":"2015-01-14T15:49:29Z","updated_at":"2016-02-22T05:17:24Z","pushed_at":"2016-03-02T21:20:17Z","git_url":"git://github.com/edx/edx-app-ios.git","ssh_url":"git@github.com:edx/edx-app-ios.git","clone_url":"https://github.com/edx/edx-app-ios.git","svn_url":"https://github.com/edx/edx-app-ios","homepage":null,"size":317496,"stargazers_count":48,"watchers_count":48,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":61,"mirror_url":null,"open_issues_count":6,"forks":61,"open_issues":6,"watchers":48,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"be09df1c3e51a5386f41be42a4adb5d6cfb62074","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":29251733,"name":"edx-app-ios","full_name":"edx/edx-app-ios","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-app-ios","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-app-ios","forks_url":"https://api.github.com/repos/edx/edx-app-ios/forks","keys_url":"https://api.github.com/repos/edx/edx-app-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-app-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-app-ios/teams","hooks_url":"https://api.github.com/repos/edx/edx-app-ios/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-app-ios/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-app-ios/events","assignees_url":"https://api.github.com/repos/edx/edx-app-ios/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-app-ios/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-app-ios/tags","blobs_url":"https://api.github.com/repos/edx/edx-app-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-app-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-app-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-app-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-app-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-app-ios/languages","stargazers_url":"https://api.github.com/repos/edx/edx-app-ios/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-app-ios/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-app-ios/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-app-ios/subscription","commits_url":"https://api.github.com/repos/edx/edx-app-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-app-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-app-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-app-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-app-ios/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-app-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-app-ios/merges","archive_url":"https://api.github.com/repos/edx/edx-app-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-app-ios/downloads","issues_url":"https://api.github.com/repos/edx/edx-app-ios/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-app-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-app-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-app-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-app-ios/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-app-ios/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-app-ios/deployments","created_at":"2015-01-14T15:49:29Z","updated_at":"2016-02-22T05:17:24Z","pushed_at":"2016-03-02T21:20:17Z","git_url":"git://github.com/edx/edx-app-ios.git","ssh_url":"git@github.com:edx/edx-app-ios.git","clone_url":"https://github.com/edx/edx-app-ios.git","svn_url":"https://github.com/edx/edx-app-ios","homepage":null,"size":317496,"stargazers_count":48,"watchers_count":48,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":61,"mirror_url":null,"open_issues_count":6,"forks":61,"open_issues":6,"watchers":48,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-app-ios/pulls/677"},"html":{"href":"https://github.com/edx/edx-app-ios/pull/677"},"issue":{"href":"https://api.github.com/repos/edx/edx-app-ios/issues/677"},"comments":{"href":"https://api.github.com/repos/edx/edx-app-ios/issues/677/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-app-ios/pulls/677/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-app-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-app-ios/pulls/677/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-app-ios/statuses/3349b518c655842d051ec32147b9bde056225aff"}}}}