{"action":"created","comment":{"url":"https://api.github.com/repos/itchio/itch/pulls/comments/50435312","id":50435312,"diff_hunk":"@@ -148,6 +149,55 @@ async function fetch_keys (type, page) {\n   cache_owned_games()\n }\n \n+async function fetch_search_page (query, page, game_ids, games) {\n+  if (typeof page === 'undefined') {\n+    page = 1\n+  }\n+\n+  if (typeof game_ids === 'undefined') {\n+    game_ids = []\n+  }\n+\n+  if (typeof games === 'undefined') {\n+    games = {}\n+  }\n+\n+  log(opts, `fetching page ${page} of search '${query}'`)\n+\n+  let user = CredentialsStore.get_current_user()\n+\n+  let res = await user.search(query, page)\n+  let total_items = res.total_items || res.per_page // FIXME: remove || res.per_page\n+  let fetched = res.per_page * page\n+  game_ids = game_ids.concat(_.pluck(res.games, 'id'))\n+  for (let game of res.games) {\n+    games[game.id] = game\n+  }\n+\n+  await db.save_games(res.games)\n+  AppActions.search_fetched(query, game_ids, games)\n+\n+  if (fetched < total_items) {\n+    await fetch_search_page(query, page + 1, games)","path":"app/stores/game-store.js","position":41,"original_position":41,"commit_id":"85db6bd7fbe301a9ccc473930d273876f2134a67","original_commit_id":"85db6bd7fbe301a9ccc473930d273876f2134a67","user":{"login":"fasterthanlime","id":7998310,"avatar_url":"https://avatars.githubusercontent.com/u/7998310?v=3","gravatar_id":"","url":"https://api.github.com/users/fasterthanlime","html_url":"https://github.com/fasterthanlime","followers_url":"https://api.github.com/users/fasterthanlime/followers","following_url":"https://api.github.com/users/fasterthanlime/following{/other_user}","gists_url":"https://api.github.com/users/fasterthanlime/gists{/gist_id}","starred_url":"https://api.github.com/users/fasterthanlime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fasterthanlime/subscriptions","organizations_url":"https://api.github.com/users/fasterthanlime/orgs","repos_url":"https://api.github.com/users/fasterthanlime/repos","events_url":"https://api.github.com/users/fasterthanlime/events{/privacy}","received_events_url":"https://api.github.com/users/fasterthanlime/received_events","type":"User","site_admin":false},"body":"Hmm, we probably shouldn't fetch all search pages in one go - as opposed to collections which we want to have available offline","created_at":"2016-01-21T17:45:05Z","updated_at":"2016-01-21T17:45:05Z","html_url":"https://github.com/itchio/itch/pull/231#discussion_r50435312","pull_request_url":"https://api.github.com/repos/itchio/itch/pulls/231","_links":{"self":{"href":"https://api.github.com/repos/itchio/itch/pulls/comments/50435312"},"html":{"href":"https://github.com/itchio/itch/pull/231#discussion_r50435312"},"pull_request":{"href":"https://api.github.com/repos/itchio/itch/pulls/231"}}},"pull_request":{"url":"https://api.github.com/repos/itchio/itch/pulls/231","id":54282516,"html_url":"https://github.com/itchio/itch/pull/231","diff_url":"https://github.com/itchio/itch/pull/231.diff","patch_url":"https://github.com/itchio/itch/pull/231.patch","issue_url":"https://api.github.com/repos/itchio/itch/issues/231","number":231,"state":"open","locked":false,"title":"Searching (WIP)","user":{"login":"Mrmaxmeier","id":3913977,"avatar_url":"https://avatars.githubusercontent.com/u/3913977?v=3","gravatar_id":"","url":"https://api.github.com/users/Mrmaxmeier","html_url":"https://github.com/Mrmaxmeier","followers_url":"https://api.github.com/users/Mrmaxmeier/followers","following_url":"https://api.github.com/users/Mrmaxmeier/following{/other_user}","gists_url":"https://api.github.com/users/Mrmaxmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/Mrmaxmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mrmaxmeier/subscriptions","organizations_url":"https://api.github.com/users/Mrmaxmeier/orgs","repos_url":"https://api.github.com/users/Mrmaxmeier/repos","events_url":"https://api.github.com/users/Mrmaxmeier/events{/privacy}","received_events_url":"https://api.github.com/users/Mrmaxmeier/received_events","type":"User","site_admin":false},"body":":construction: WIP\r\n\r\nTo-dos\r\n- [x] update state on result \r\n- [x] make component stateless\r\n- [ ] ui and ux that doesn't suck\r\n  - [x] activity indicator\r\n    - [ ] make it pretty / smaller\r\n  - [x] empty state\r\n- [x] update icomoon to include 'search' icon\r\n- [ ] implement pagination\r\n  - [ ] have api return total amount of games\r\n- [x] test coverage\r\n- [x] fix result sorting\r\n- [x] deal with order of responses\r\n- [ ] fix merge conflicts","created_at":"2015-12-21T17:36:04Z","updated_at":"2016-01-21T17:45:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"91940f97bc5d41e48efa3c689ce2c2115f65cc41","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/itchio/itch/pulls/231/commits","review_comments_url":"https://api.github.com/repos/itchio/itch/pulls/231/comments","review_comment_url":"https://api.github.com/repos/itchio/itch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/itchio/itch/issues/231/comments","statuses_url":"https://api.github.com/repos/itchio/itch/statuses/85db6bd7fbe301a9ccc473930d273876f2134a67","head":{"label":"Mrmaxmeier:search-games","ref":"search-games","sha":"85db6bd7fbe301a9ccc473930d273876f2134a67","user":{"login":"Mrmaxmeier","id":3913977,"avatar_url":"https://avatars.githubusercontent.com/u/3913977?v=3","gravatar_id":"","url":"https://api.github.com/users/Mrmaxmeier","html_url":"https://github.com/Mrmaxmeier","followers_url":"https://api.github.com/users/Mrmaxmeier/followers","following_url":"https://api.github.com/users/Mrmaxmeier/following{/other_user}","gists_url":"https://api.github.com/users/Mrmaxmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/Mrmaxmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mrmaxmeier/subscriptions","organizations_url":"https://api.github.com/users/Mrmaxmeier/orgs","repos_url":"https://api.github.com/users/Mrmaxmeier/repos","events_url":"https://api.github.com/users/Mrmaxmeier/events{/privacy}","received_events_url":"https://api.github.com/users/Mrmaxmeier/received_events","type":"User","site_admin":false},"repo":{"id":48000553,"name":"itch","full_name":"Mrmaxmeier/itch","owner":{"login":"Mrmaxmeier","id":3913977,"avatar_url":"https://avatars.githubusercontent.com/u/3913977?v=3","gravatar_id":"","url":"https://api.github.com/users/Mrmaxmeier","html_url":"https://github.com/Mrmaxmeier","followers_url":"https://api.github.com/users/Mrmaxmeier/followers","following_url":"https://api.github.com/users/Mrmaxmeier/following{/other_user}","gists_url":"https://api.github.com/users/Mrmaxmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/Mrmaxmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mrmaxmeier/subscriptions","organizations_url":"https://api.github.com/users/Mrmaxmeier/orgs","repos_url":"https://api.github.com/users/Mrmaxmeier/repos","events_url":"https://api.github.com/users/Mrmaxmeier/events{/privacy}","received_events_url":"https://api.github.com/users/Mrmaxmeier/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Mrmaxmeier/itch","description":":video_game: The best way to play your itch.io games","fork":true,"url":"https://api.github.com/repos/Mrmaxmeier/itch","forks_url":"https://api.github.com/repos/Mrmaxmeier/itch/forks","keys_url":"https://api.github.com/repos/Mrmaxmeier/itch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mrmaxmeier/itch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mrmaxmeier/itch/teams","hooks_url":"https://api.github.com/repos/Mrmaxmeier/itch/hooks","issue_events_url":"https://api.github.com/repos/Mrmaxmeier/itch/issues/events{/number}","events_url":"https://api.github.com/repos/Mrmaxmeier/itch/events","assignees_url":"https://api.github.com/repos/Mrmaxmeier/itch/assignees{/user}","branches_url":"https://api.github.com/repos/Mrmaxmeier/itch/branches{/branch}","tags_url":"https://api.github.com/repos/Mrmaxmeier/itch/tags","blobs_url":"https://api.github.com/repos/Mrmaxmeier/itch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mrmaxmeier/itch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mrmaxmeier/itch/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mrmaxmeier/itch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mrmaxmeier/itch/statuses/{sha}","languages_url":"https://api.github.com/repos/Mrmaxmeier/itch/languages","stargazers_url":"https://api.github.com/repos/Mrmaxmeier/itch/stargazers","contributors_url":"https://api.github.com/repos/Mrmaxmeier/itch/contributors","subscribers_url":"https://api.github.com/repos/Mrmaxmeier/itch/subscribers","subscription_url":"https://api.github.com/repos/Mrmaxmeier/itch/subscription","commits_url":"https://api.github.com/repos/Mrmaxmeier/itch/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mrmaxmeier/itch/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mrmaxmeier/itch/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mrmaxmeier/itch/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mrmaxmeier/itch/contents/{+path}","compare_url":"https://api.github.com/repos/Mrmaxmeier/itch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mrmaxmeier/itch/merges","archive_url":"https://api.github.com/repos/Mrmaxmeier/itch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mrmaxmeier/itch/downloads","issues_url":"https://api.github.com/repos/Mrmaxmeier/itch/issues{/number}","pulls_url":"https://api.github.com/repos/Mrmaxmeier/itch/pulls{/number}","milestones_url":"https://api.github.com/repos/Mrmaxmeier/itch/milestones{/number}","notifications_url":"https://api.github.com/repos/Mrmaxmeier/itch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mrmaxmeier/itch/labels{/name}","releases_url":"https://api.github.com/repos/Mrmaxmeier/itch/releases{/id}","created_at":"2015-12-14T20:51:57Z","updated_at":"2016-01-08T14:41:15Z","pushed_at":"2016-01-16T19:46:34Z","git_url":"git://github.com/Mrmaxmeier/itch.git","ssh_url":"git@github.com:Mrmaxmeier/itch.git","clone_url":"https://github.com/Mrmaxmeier/itch.git","svn_url":"https://github.com/Mrmaxmeier/itch","homepage":"https://itch.io/app","size":3574,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"itchio:master","ref":"master","sha":"bd141a0df98679633c2f2d43414ef2b330224a0e","user":{"login":"itchio","id":14803619,"avatar_url":"https://avatars.githubusercontent.com/u/14803619?v=3","gravatar_id":"","url":"https://api.github.com/users/itchio","html_url":"https://github.com/itchio","followers_url":"https://api.github.com/users/itchio/followers","following_url":"https://api.github.com/users/itchio/following{/other_user}","gists_url":"https://api.github.com/users/itchio/gists{/gist_id}","starred_url":"https://api.github.com/users/itchio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itchio/subscriptions","organizations_url":"https://api.github.com/users/itchio/orgs","repos_url":"https://api.github.com/users/itchio/repos","events_url":"https://api.github.com/users/itchio/events{/privacy}","received_events_url":"https://api.github.com/users/itchio/received_events","type":"Organization","site_admin":false},"repo":{"id":35249369,"name":"itch","full_name":"itchio/itch","owner":{"login":"itchio","id":14803619,"avatar_url":"https://avatars.githubusercontent.com/u/14803619?v=3","gravatar_id":"","url":"https://api.github.com/users/itchio","html_url":"https://github.com/itchio","followers_url":"https://api.github.com/users/itchio/followers","following_url":"https://api.github.com/users/itchio/following{/other_user}","gists_url":"https://api.github.com/users/itchio/gists{/gist_id}","starred_url":"https://api.github.com/users/itchio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itchio/subscriptions","organizations_url":"https://api.github.com/users/itchio/orgs","repos_url":"https://api.github.com/users/itchio/repos","events_url":"https://api.github.com/users/itchio/events{/privacy}","received_events_url":"https://api.github.com/users/itchio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/itchio/itch","description":":video_game: The best way to play your itch.io games","fork":false,"url":"https://api.github.com/repos/itchio/itch","forks_url":"https://api.github.com/repos/itchio/itch/forks","keys_url":"https://api.github.com/repos/itchio/itch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/itchio/itch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/itchio/itch/teams","hooks_url":"https://api.github.com/repos/itchio/itch/hooks","issue_events_url":"https://api.github.com/repos/itchio/itch/issues/events{/number}","events_url":"https://api.github.com/repos/itchio/itch/events","assignees_url":"https://api.github.com/repos/itchio/itch/assignees{/user}","branches_url":"https://api.github.com/repos/itchio/itch/branches{/branch}","tags_url":"https://api.github.com/repos/itchio/itch/tags","blobs_url":"https://api.github.com/repos/itchio/itch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/itchio/itch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/itchio/itch/git/refs{/sha}","trees_url":"https://api.github.com/repos/itchio/itch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/itchio/itch/statuses/{sha}","languages_url":"https://api.github.com/repos/itchio/itch/languages","stargazers_url":"https://api.github.com/repos/itchio/itch/stargazers","contributors_url":"https://api.github.com/repos/itchio/itch/contributors","subscribers_url":"https://api.github.com/repos/itchio/itch/subscribers","subscription_url":"https://api.github.com/repos/itchio/itch/subscription","commits_url":"https://api.github.com/repos/itchio/itch/commits{/sha}","git_commits_url":"https://api.github.com/repos/itchio/itch/git/commits{/sha}","comments_url":"https://api.github.com/repos/itchio/itch/comments{/number}","issue_comment_url":"https://api.github.com/repos/itchio/itch/issues/comments{/number}","contents_url":"https://api.github.com/repos/itchio/itch/contents/{+path}","compare_url":"https://api.github.com/repos/itchio/itch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/itchio/itch/merges","archive_url":"https://api.github.com/repos/itchio/itch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/itchio/itch/downloads","issues_url":"https://api.github.com/repos/itchio/itch/issues{/number}","pulls_url":"https://api.github.com/repos/itchio/itch/pulls{/number}","milestones_url":"https://api.github.com/repos/itchio/itch/milestones{/number}","notifications_url":"https://api.github.com/repos/itchio/itch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/itchio/itch/labels{/name}","releases_url":"https://api.github.com/repos/itchio/itch/releases{/id}","created_at":"2015-05-07T23:58:36Z","updated_at":"2016-01-20T22:07:41Z","pushed_at":"2016-01-21T17:43:48Z","git_url":"git://github.com/itchio/itch.git","ssh_url":"git@github.com:itchio/itch.git","clone_url":"https://github.com/itchio/itch.git","svn_url":"https://github.com/itchio/itch","homepage":"https://itch.io/app","size":3601,"stargazers_count":234,"watchers_count":234,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":67,"forks":15,"open_issues":67,"watchers":234,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/itchio/itch/pulls/231"},"html":{"href":"https://github.com/itchio/itch/pull/231"},"issue":{"href":"https://api.github.com/repos/itchio/itch/issues/231"},"comments":{"href":"https://api.github.com/repos/itchio/itch/issues/231/comments"},"review_comments":{"href":"https://api.github.com/repos/itchio/itch/pulls/231/comments"},"review_comment":{"href":"https://api.github.com/repos/itchio/itch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/itchio/itch/pulls/231/commits"},"statuses":{"href":"https://api.github.com/repos/itchio/itch/statuses/85db6bd7fbe301a9ccc473930d273876f2134a67"}}}}