{"action":"created","comment":{"url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/comments/48409620","id":48409620,"diff_hunk":"@@ -1901,6 +1902,71 @@ MatrixClient.prototype.scrollback = function(room, limit, callback) {\n     return defer.promise;\n };\n \n+/**\n+ * Take an EventContext, and back/forward-fill results.\n+ *\n+ * @param {module:models/event-context.EventContext} eventContext  context\n+ *    object to be updated\n+ * @param {boolean} backwards  true to fill backwards, false to go forwards\n+ *\n+ * @return {module:client.Promise} Resolves: updated EventContext object\n+ * @return {module:http-api.MatrixError} Rejects: with an error response.\n+ */\n+MatrixClient.prototype.paginateEventContext = function(eventContext, backwards) {\n+    // TODO: we should implement a backoff (as per scrollback()) to deal more\n+    // nicely with HTTP errors.\n+\n+    var token = eventContext.getPaginateToken(backwards);\n+    if (!token) {\n+        // no more results.\n+        throw new Error(\"No paginate token\");\n+    }\n+\n+    var dir = backwards ? 'b' : 'f';\n+    var pendingRequest = eventContext._paginateRequests[dir];\n+\n+    if (pendingRequest) {\n+        // already a request in progress - return the existing promise\n+        return pendingRequest;\n+    }\n+\n+    var path = utils.encodeUri(\n+        \"/rooms/$roomId/messages\", {$roomId: eventContext.getEvent().getRoomId()}\n+    );\n+    var params = {\n+        from: token,\n+        limit: 30,","path":"lib/client.js","position":45,"original_position":45,"commit_id":"5d4de0b439ec605a59c97ebfbd6b04098781ea90","original_commit_id":"5d4de0b439ec605a59c97ebfbd6b04098781ea90","user":{"login":"richvdh","id":1389908,"avatar_url":"https://avatars.githubusercontent.com/u/1389908?v=3","gravatar_id":"","url":"https://api.github.com/users/richvdh","html_url":"https://github.com/richvdh","followers_url":"https://api.github.com/users/richvdh/followers","following_url":"https://api.github.com/users/richvdh/following{/other_user}","gists_url":"https://api.github.com/users/richvdh/gists{/gist_id}","starred_url":"https://api.github.com/users/richvdh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richvdh/subscriptions","organizations_url":"https://api.github.com/users/richvdh/orgs","repos_url":"https://api.github.com/users/richvdh/repos","events_url":"https://api.github.com/users/richvdh/events{/privacy}","received_events_url":"https://api.github.com/users/richvdh/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2015-12-24T11:00:14Z","updated_at":"2015-12-24T11:00:14Z","html_url":"https://github.com/matrix-org/matrix-js-sdk/pull/59#discussion_r48409620","pull_request_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/59","_links":{"self":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/comments/48409620"},"html":{"href":"https://github.com/matrix-org/matrix-js-sdk/pull/59#discussion_r48409620"},"pull_request":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/59"}}},"pull_request":{"url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/59","id":54516754,"html_url":"https://github.com/matrix-org/matrix-js-sdk/pull/59","diff_url":"https://github.com/matrix-org/matrix-js-sdk/pull/59.diff","patch_url":"https://github.com/matrix-org/matrix-js-sdk/pull/59.patch","issue_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues/59","number":59,"state":"open","locked":false,"title":"Enhancements to search results, and event context implementation","user":{"login":"richvdh","id":1389908,"avatar_url":"https://avatars.githubusercontent.com/u/1389908?v=3","gravatar_id":"","url":"https://api.github.com/users/richvdh","html_url":"https://github.com/richvdh","followers_url":"https://api.github.com/users/richvdh/followers","following_url":"https://api.github.com/users/richvdh/following{/other_user}","gists_url":"https://api.github.com/users/richvdh/gists{/gist_id}","starred_url":"https://api.github.com/users/richvdh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richvdh/subscriptions","organizations_url":"https://api.github.com/users/richvdh/orgs","repos_url":"https://api.github.com/users/richvdh/repos","events_url":"https://api.github.com/users/richvdh/events{/privacy}","received_events_url":"https://api.github.com/users/richvdh/received_events","type":"User","site_admin":false},"body":"This change adds support to the JDK for processing the results of a room\nsearch, as well as back-paginating the results.\n\nIt treats each search result as a 'context' object, which can itself be\nbackwards or forward-paginated.","created_at":"2015-12-24T00:01:01Z","updated_at":"2015-12-24T11:00:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6a367d0ce8cbff4c7b50244634ef4d8c42ddc53","assignee":{"login":"richvdh","id":1389908,"avatar_url":"https://avatars.githubusercontent.com/u/1389908?v=3","gravatar_id":"","url":"https://api.github.com/users/richvdh","html_url":"https://github.com/richvdh","followers_url":"https://api.github.com/users/richvdh/followers","following_url":"https://api.github.com/users/richvdh/following{/other_user}","gists_url":"https://api.github.com/users/richvdh/gists{/gist_id}","starred_url":"https://api.github.com/users/richvdh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richvdh/subscriptions","organizations_url":"https://api.github.com/users/richvdh/orgs","repos_url":"https://api.github.com/users/richvdh/repos","events_url":"https://api.github.com/users/richvdh/events{/privacy}","received_events_url":"https://api.github.com/users/richvdh/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/59/commits","review_comments_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/59/comments","review_comment_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues/59/comments","statuses_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/statuses/5d4de0b439ec605a59c97ebfbd6b04098781ea90","head":{"label":"matrix-org:rav/event_context","ref":"rav/event_context","sha":"5d4de0b439ec605a59c97ebfbd6b04098781ea90","user":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":31670053,"name":"matrix-js-sdk","full_name":"matrix-org/matrix-js-sdk","owner":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matrix-org/matrix-js-sdk","description":"Matrix Client-Server SDK for JavaScript","fork":false,"url":"https://api.github.com/repos/matrix-org/matrix-js-sdk","forks_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/forks","keys_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/teams","hooks_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/events","assignees_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/tags","blobs_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/languages","stargazers_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/subscription","commits_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/merges","archive_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/downloads","issues_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/releases{/id}","created_at":"2015-03-04T17:28:51Z","updated_at":"2015-12-21T19:51:17Z","pushed_at":"2015-12-24T08:39:08Z","git_url":"git://github.com/matrix-org/matrix-js-sdk.git","ssh_url":"git@github.com:matrix-org/matrix-js-sdk.git","clone_url":"https://github.com/matrix-org/matrix-js-sdk.git","svn_url":"https://github.com/matrix-org/matrix-js-sdk","homepage":"","size":2107,"stargazers_count":18,"watchers_count":18,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":5,"forks":7,"open_issues":5,"watchers":18,"default_branch":"master"}},"base":{"label":"matrix-org:develop","ref":"develop","sha":"3e4cef89fd823eb15a66e64d697efb61c8142997","user":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":31670053,"name":"matrix-js-sdk","full_name":"matrix-org/matrix-js-sdk","owner":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matrix-org/matrix-js-sdk","description":"Matrix Client-Server SDK for JavaScript","fork":false,"url":"https://api.github.com/repos/matrix-org/matrix-js-sdk","forks_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/forks","keys_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/teams","hooks_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/events","assignees_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/tags","blobs_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/languages","stargazers_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/subscription","commits_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/merges","archive_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/downloads","issues_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/matrix-js-sdk/releases{/id}","created_at":"2015-03-04T17:28:51Z","updated_at":"2015-12-21T19:51:17Z","pushed_at":"2015-12-24T08:39:08Z","git_url":"git://github.com/matrix-org/matrix-js-sdk.git","ssh_url":"git@github.com:matrix-org/matrix-js-sdk.git","clone_url":"https://github.com/matrix-org/matrix-js-sdk.git","svn_url":"https://github.com/matrix-org/matrix-js-sdk","homepage":"","size":2107,"stargazers_count":18,"watchers_count":18,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":5,"forks":7,"open_issues":5,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/59"},"html":{"href":"https://github.com/matrix-org/matrix-js-sdk/pull/59"},"issue":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues/59"},"comments":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/issues/59/comments"},"review_comments":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/59/comments"},"review_comment":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/pulls/59/commits"},"statuses":{"href":"https://api.github.com/repos/matrix-org/matrix-js-sdk/statuses/5d4de0b439ec605a59c97ebfbd6b04098781ea90"}}}}