{"action":"created","comment":{"url":"https://api.github.com/repos/cozy/cozy-drive/pulls/comments/173843715","pull_request_review_id":103099348,"id":173843715,"diff_hunk":"@@ -64,10 +69,8 @@ export class PhotoList extends Component {\n       }\n     )\n \n-    const photoIds = photos.map(p => p.id)\n-    const allSelected =\n-      selected.length === photoIds.length &&\n-      selected.every(id => photoIds.indexOf(id) !== -1)\n+    const selectedIds = selected.map(p => p._id)\n+    const allSelected = photos.every(p => selectedIds.indexOf(p._id) !== -1)","path":"src/photos/components/PhotoList.jsx","position":21,"original_position":21,"commit_id":"3debbf374c317a67aee180de25afe2e176e41778","original_commit_id":"3debbf374c317a67aee180de25afe2e176e41778","user":{"login":"edas","id":15271,"avatar_url":"https://avatars0.githubusercontent.com/u/15271?v=4","gravatar_id":"","url":"https://api.github.com/users/edas","html_url":"https://github.com/edas","followers_url":"https://api.github.com/users/edas/followers","following_url":"https://api.github.com/users/edas/following{/other_user}","gists_url":"https://api.github.com/users/edas/gists{/gist_id}","starred_url":"https://api.github.com/users/edas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edas/subscriptions","organizations_url":"https://api.github.com/users/edas/orgs","repos_url":"https://api.github.com/users/edas/repos","events_url":"https://api.github.com/users/edas/events{/privacy}","received_events_url":"https://api.github.com/users/edas/received_events","type":"User","site_admin":false},"body":"what is the difference betweet `selected` and `allSelected` ?","created_at":"2018-03-12T15:43:32Z","updated_at":"2018-03-12T15:43:32Z","html_url":"https://github.com/cozy/cozy-drive/pull/805#discussion_r173843715","pull_request_url":"https://api.github.com/repos/cozy/cozy-drive/pulls/805","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/cozy/cozy-drive/pulls/comments/173843715"},"html":{"href":"https://github.com/cozy/cozy-drive/pull/805#discussion_r173843715"},"pull_request":{"href":"https://api.github.com/repos/cozy/cozy-drive/pulls/805"}}},"pull_request":{"url":"https://api.github.com/repos/cozy/cozy-drive/pulls/805","id":173984875,"html_url":"https://github.com/cozy/cozy-drive/pull/805","diff_url":"https://github.com/cozy/cozy-drive/pull/805.diff","patch_url":"https://github.com/cozy/cozy-drive/pull/805.patch","issue_url":"https://api.github.com/repos/cozy/cozy-drive/issues/805","number":805,"state":"open","locked":false,"title":"[WIP] Added new cozy-client to Photos","user":{"login":"goldoraf","id":5461,"avatar_url":"https://avatars3.githubusercontent.com/u/5461?v=4","gravatar_id":"","url":"https://api.github.com/users/goldoraf","html_url":"https://github.com/goldoraf","followers_url":"https://api.github.com/users/goldoraf/followers","following_url":"https://api.github.com/users/goldoraf/following{/other_user}","gists_url":"https://api.github.com/users/goldoraf/gists{/gist_id}","starred_url":"https://api.github.com/users/goldoraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldoraf/subscriptions","organizations_url":"https://api.github.com/users/goldoraf/orgs","repos_url":"https://api.github.com/users/goldoraf/repos","events_url":"https://api.github.com/users/goldoraf/events{/privacy}","received_events_url":"https://api.github.com/users/goldoraf/received_events","type":"User","site_admin":false},"body":"C'est (hélas) une PR avec beaucoup de changements car j'ai déplacé beaucoup de code, ce ne sera donc pas facile à relire. J'espère que mes commentaires vous y aideront.\r\n\r\nUne première chose à noter est la réorganisation des ducks `timeline` et `albums` : \r\n - il n'y a plus de dossier `containers`, tout (ou presque) les composants sont dans les ducks à part les composants très génériques (et dumb) ;\r\n - tous les composants dans le dossier `components` de chaque duck sont dumbs ou du moins, ils ne sont pas eux-même connectés au store ou au client ;\r\n - la connection au client, aux requêtes, aux mutations et à la sélection de ces composants se fait dans le `index.js` de chaque duck, en plus de la déclaration de ces requêtes et mutations. Je trouve que l'on y gagne en consistance et en compréhension du code.\r\n\r\nNotez également que cette connection se fait avec des [composants à render prop](https://reactjs.org/docs/render-props.html) : c'est non seulement une recommandation officielle de l'équipe React désormais, mais je constate qu'effectivement cela permet d'écrire des choses beaucoup plus lisibles et compréhensibles qu'avec des HOCs : https://github.com/cozy/cozy-drive/pull/805/files#diff-1d5352effec4e22611290b438eb600deR105\r\n\r\nTL; DR:\r\nAvec le schéma (fourni à cozy-client) : \r\n```js\r\nexport default {\r\n  albums: {\r\n    doctype: 'io.cozy.photos.albums',\r\n    relationships: {\r\n      photos: {\r\n        type: 'has-many',\r\n        doctype: 'io.cozy.files'\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\nOn peut faire :\r\n```jsx\r\n// récupérer les photos en plus des albums\r\nconst ALBUM_QUERY = (client, ownProps) =>\r\n  client.get(DOCTYPE, ownProps.router.params.albumId).include(['photos'])\r\n\r\n// nouvelle API pour les mutations, remarquez que ça ressemble assez à un mapDispatchToProps\r\nconst ALBUM_MUTATIONS = (mutate, ownProps) => ({\r\n  updateAlbum: album => mutate(client => client.save(album)),\r\n  deleteAlbum: album =>\r\n    mutate(client => client.destroy(album), {\r\n      updateQueries: {\r\n        albums: (previousData, result) =>\r\n          previousData.filter(a => a.id !== album.id)\r\n      }\r\n    })\r\n})\r\n\r\n// \"Undumbisation\" de AlbumPhotos\r\nconst ConnectedAlbumPhotos = withRouter(props => (\r\n  <Mutations mutations={ALBUM_MUTATIONS}>\r\n    {({ updateAlbum }) => (\r\n      <Selection actions={{}}>\r\n        {(selected, active, selection) => (\r\n          <Query query={ALBUM_QUERY} {...props}>\r\n            {({ data }) => (\r\n              <AlbumPhotos\r\n                album={data ? data[0] : null}\r\n                updateAlbum={updateAlbum}\r\n                selected={selected}\r\n                showSelection={active}\r\n                selection={selection}\r\n                {...props}\r\n              />\r\n            )}\r\n          </Query>\r\n        )}\r\n      </Selection>\r\n    )}\r\n  </Mutations>\r\n))\r\n```","created_at":"2018-03-09T11:42:39Z","updated_at":"2018-03-12T15:43:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4431a8c007c481d34272ae6c7d1d3e1d3bb4819","assignee":null,"assignees":[],"requested_reviewers":[{"login":"enguerran","id":701648,"avatar_url":"https://avatars1.githubusercontent.com/u/701648?v=4","gravatar_id":"","url":"https://api.github.com/users/enguerran","html_url":"https://github.com/enguerran","followers_url":"https://api.github.com/users/enguerran/followers","following_url":"https://api.github.com/users/enguerran/following{/other_user}","gists_url":"https://api.github.com/users/enguerran/gists{/gist_id}","starred_url":"https://api.github.com/users/enguerran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enguerran/subscriptions","organizations_url":"https://api.github.com/users/enguerran/orgs","repos_url":"https://api.github.com/users/enguerran/repos","events_url":"https://api.github.com/users/enguerran/events{/privacy}","received_events_url":"https://api.github.com/users/enguerran/received_events","type":"User","site_admin":false},{"login":"y-lohse","id":2261445,"avatar_url":"https://avatars2.githubusercontent.com/u/2261445?v=4","gravatar_id":"","url":"https://api.github.com/users/y-lohse","html_url":"https://github.com/y-lohse","followers_url":"https://api.github.com/users/y-lohse/followers","following_url":"https://api.github.com/users/y-lohse/following{/other_user}","gists_url":"https://api.github.com/users/y-lohse/gists{/gist_id}","starred_url":"https://api.github.com/users/y-lohse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/y-lohse/subscriptions","organizations_url":"https://api.github.com/users/y-lohse/orgs","repos_url":"https://api.github.com/users/y-lohse/repos","events_url":"https://api.github.com/users/y-lohse/events{/privacy}","received_events_url":"https://api.github.com/users/y-lohse/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cozy/cozy-drive/pulls/805/commits","review_comments_url":"https://api.github.com/repos/cozy/cozy-drive/pulls/805/comments","review_comment_url":"https://api.github.com/repos/cozy/cozy-drive/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cozy/cozy-drive/issues/805/comments","statuses_url":"https://api.github.com/repos/cozy/cozy-drive/statuses/3debbf374c317a67aee180de25afe2e176e41778","head":{"label":"goldoraf:new-cozy-client","ref":"new-cozy-client","sha":"3debbf374c317a67aee180de25afe2e176e41778","user":{"login":"goldoraf","id":5461,"avatar_url":"https://avatars3.githubusercontent.com/u/5461?v=4","gravatar_id":"","url":"https://api.github.com/users/goldoraf","html_url":"https://github.com/goldoraf","followers_url":"https://api.github.com/users/goldoraf/followers","following_url":"https://api.github.com/users/goldoraf/following{/other_user}","gists_url":"https://api.github.com/users/goldoraf/gists{/gist_id}","starred_url":"https://api.github.com/users/goldoraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldoraf/subscriptions","organizations_url":"https://api.github.com/users/goldoraf/orgs","repos_url":"https://api.github.com/users/goldoraf/repos","events_url":"https://api.github.com/users/goldoraf/events{/privacy}","received_events_url":"https://api.github.com/users/goldoraf/received_events","type":"User","site_admin":false},"repo":{"id":87427103,"name":"cozy-drive","full_name":"goldoraf/cozy-drive","owner":{"login":"goldoraf","id":5461,"avatar_url":"https://avatars3.githubusercontent.com/u/5461?v=4","gravatar_id":"","url":"https://api.github.com/users/goldoraf","html_url":"https://github.com/goldoraf","followers_url":"https://api.github.com/users/goldoraf/followers","following_url":"https://api.github.com/users/goldoraf/following{/other_user}","gists_url":"https://api.github.com/users/goldoraf/gists{/gist_id}","starred_url":"https://api.github.com/users/goldoraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldoraf/subscriptions","organizations_url":"https://api.github.com/users/goldoraf/orgs","repos_url":"https://api.github.com/users/goldoraf/repos","events_url":"https://api.github.com/users/goldoraf/events{/privacy}","received_events_url":"https://api.github.com/users/goldoraf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/goldoraf/cozy-drive","description":"Cozy Drive app for Cozy Cloud","fork":true,"url":"https://api.github.com/repos/goldoraf/cozy-drive","forks_url":"https://api.github.com/repos/goldoraf/cozy-drive/forks","keys_url":"https://api.github.com/repos/goldoraf/cozy-drive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/goldoraf/cozy-drive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/goldoraf/cozy-drive/teams","hooks_url":"https://api.github.com/repos/goldoraf/cozy-drive/hooks","issue_events_url":"https://api.github.com/repos/goldoraf/cozy-drive/issues/events{/number}","events_url":"https://api.github.com/repos/goldoraf/cozy-drive/events","assignees_url":"https://api.github.com/repos/goldoraf/cozy-drive/assignees{/user}","branches_url":"https://api.github.com/repos/goldoraf/cozy-drive/branches{/branch}","tags_url":"https://api.github.com/repos/goldoraf/cozy-drive/tags","blobs_url":"https://api.github.com/repos/goldoraf/cozy-drive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/goldoraf/cozy-drive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/goldoraf/cozy-drive/git/refs{/sha}","trees_url":"https://api.github.com/repos/goldoraf/cozy-drive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/goldoraf/cozy-drive/statuses/{sha}","languages_url":"https://api.github.com/repos/goldoraf/cozy-drive/languages","stargazers_url":"https://api.github.com/repos/goldoraf/cozy-drive/stargazers","contributors_url":"https://api.github.com/repos/goldoraf/cozy-drive/contributors","subscribers_url":"https://api.github.com/repos/goldoraf/cozy-drive/subscribers","subscription_url":"https://api.github.com/repos/goldoraf/cozy-drive/subscription","commits_url":"https://api.github.com/repos/goldoraf/cozy-drive/commits{/sha}","git_commits_url":"https://api.github.com/repos/goldoraf/cozy-drive/git/commits{/sha}","comments_url":"https://api.github.com/repos/goldoraf/cozy-drive/comments{/number}","issue_comment_url":"https://api.github.com/repos/goldoraf/cozy-drive/issues/comments{/number}","contents_url":"https://api.github.com/repos/goldoraf/cozy-drive/contents/{+path}","compare_url":"https://api.github.com/repos/goldoraf/cozy-drive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/goldoraf/cozy-drive/merges","archive_url":"https://api.github.com/repos/goldoraf/cozy-drive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/goldoraf/cozy-drive/downloads","issues_url":"https://api.github.com/repos/goldoraf/cozy-drive/issues{/number}","pulls_url":"https://api.github.com/repos/goldoraf/cozy-drive/pulls{/number}","milestones_url":"https://api.github.com/repos/goldoraf/cozy-drive/milestones{/number}","notifications_url":"https://api.github.com/repos/goldoraf/cozy-drive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/goldoraf/cozy-drive/labels{/name}","releases_url":"https://api.github.com/repos/goldoraf/cozy-drive/releases{/id}","deployments_url":"https://api.github.com/repos/goldoraf/cozy-drive/deployments","created_at":"2017-04-06T12:30:51Z","updated_at":"2017-04-06T12:30:52Z","pushed_at":"2018-03-09T11:42:05Z","git_url":"git://github.com/goldoraf/cozy-drive.git","ssh_url":"git@github.com:goldoraf/cozy-drive.git","clone_url":"https://github.com/goldoraf/cozy-drive.git","svn_url":"https://github.com/goldoraf/cozy-drive","homepage":"","size":20109,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cozy:master","ref":"master","sha":"911f9c6865313d436a70cb038a99b9f0285615ef","user":{"login":"cozy","id":7690525,"avatar_url":"https://avatars0.githubusercontent.com/u/7690525?v=4","gravatar_id":"","url":"https://api.github.com/users/cozy","html_url":"https://github.com/cozy","followers_url":"https://api.github.com/users/cozy/followers","following_url":"https://api.github.com/users/cozy/following{/other_user}","gists_url":"https://api.github.com/users/cozy/gists{/gist_id}","starred_url":"https://api.github.com/users/cozy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozy/subscriptions","organizations_url":"https://api.github.com/users/cozy/orgs","repos_url":"https://api.github.com/users/cozy/repos","events_url":"https://api.github.com/users/cozy/events{/privacy}","received_events_url":"https://api.github.com/users/cozy/received_events","type":"Organization","site_admin":false},"repo":{"id":76205055,"name":"cozy-drive","full_name":"cozy/cozy-drive","owner":{"login":"cozy","id":7690525,"avatar_url":"https://avatars0.githubusercontent.com/u/7690525?v=4","gravatar_id":"","url":"https://api.github.com/users/cozy","html_url":"https://github.com/cozy","followers_url":"https://api.github.com/users/cozy/followers","following_url":"https://api.github.com/users/cozy/following{/other_user}","gists_url":"https://api.github.com/users/cozy/gists{/gist_id}","starred_url":"https://api.github.com/users/cozy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cozy/subscriptions","organizations_url":"https://api.github.com/users/cozy/orgs","repos_url":"https://api.github.com/users/cozy/repos","events_url":"https://api.github.com/users/cozy/events{/privacy}","received_events_url":"https://api.github.com/users/cozy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cozy/cozy-drive","description":"Cozy Drive app for Cozy Cloud","fork":false,"url":"https://api.github.com/repos/cozy/cozy-drive","forks_url":"https://api.github.com/repos/cozy/cozy-drive/forks","keys_url":"https://api.github.com/repos/cozy/cozy-drive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cozy/cozy-drive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cozy/cozy-drive/teams","hooks_url":"https://api.github.com/repos/cozy/cozy-drive/hooks","issue_events_url":"https://api.github.com/repos/cozy/cozy-drive/issues/events{/number}","events_url":"https://api.github.com/repos/cozy/cozy-drive/events","assignees_url":"https://api.github.com/repos/cozy/cozy-drive/assignees{/user}","branches_url":"https://api.github.com/repos/cozy/cozy-drive/branches{/branch}","tags_url":"https://api.github.com/repos/cozy/cozy-drive/tags","blobs_url":"https://api.github.com/repos/cozy/cozy-drive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cozy/cozy-drive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cozy/cozy-drive/git/refs{/sha}","trees_url":"https://api.github.com/repos/cozy/cozy-drive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cozy/cozy-drive/statuses/{sha}","languages_url":"https://api.github.com/repos/cozy/cozy-drive/languages","stargazers_url":"https://api.github.com/repos/cozy/cozy-drive/stargazers","contributors_url":"https://api.github.com/repos/cozy/cozy-drive/contributors","subscribers_url":"https://api.github.com/repos/cozy/cozy-drive/subscribers","subscription_url":"https://api.github.com/repos/cozy/cozy-drive/subscription","commits_url":"https://api.github.com/repos/cozy/cozy-drive/commits{/sha}","git_commits_url":"https://api.github.com/repos/cozy/cozy-drive/git/commits{/sha}","comments_url":"https://api.github.com/repos/cozy/cozy-drive/comments{/number}","issue_comment_url":"https://api.github.com/repos/cozy/cozy-drive/issues/comments{/number}","contents_url":"https://api.github.com/repos/cozy/cozy-drive/contents/{+path}","compare_url":"https://api.github.com/repos/cozy/cozy-drive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cozy/cozy-drive/merges","archive_url":"https://api.github.com/repos/cozy/cozy-drive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cozy/cozy-drive/downloads","issues_url":"https://api.github.com/repos/cozy/cozy-drive/issues{/number}","pulls_url":"https://api.github.com/repos/cozy/cozy-drive/pulls{/number}","milestones_url":"https://api.github.com/repos/cozy/cozy-drive/milestones{/number}","notifications_url":"https://api.github.com/repos/cozy/cozy-drive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cozy/cozy-drive/labels{/name}","releases_url":"https://api.github.com/repos/cozy/cozy-drive/releases{/id}","deployments_url":"https://api.github.com/repos/cozy/cozy-drive/deployments","created_at":"2016-12-11T22:51:29Z","updated_at":"2018-03-12T15:24:59Z","pushed_at":"2018-03-12T14:24:38Z","git_url":"git://github.com/cozy/cozy-drive.git","ssh_url":"git@github.com:cozy/cozy-drive.git","clone_url":"https://github.com/cozy/cozy-drive.git","svn_url":"https://github.com/cozy/cozy-drive","homepage":"","size":92743,"stargazers_count":16,"watchers_count":16,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":29,"open_issues":34,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cozy/cozy-drive/pulls/805"},"html":{"href":"https://github.com/cozy/cozy-drive/pull/805"},"issue":{"href":"https://api.github.com/repos/cozy/cozy-drive/issues/805"},"comments":{"href":"https://api.github.com/repos/cozy/cozy-drive/issues/805/comments"},"review_comments":{"href":"https://api.github.com/repos/cozy/cozy-drive/pulls/805/comments"},"review_comment":{"href":"https://api.github.com/repos/cozy/cozy-drive/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cozy/cozy-drive/pulls/805/commits"},"statuses":{"href":"https://api.github.com/repos/cozy/cozy-drive/statuses/3debbf374c317a67aee180de25afe2e176e41778"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"edas"}}