Skip to content

refactor(redux): Switch to redux middleware & normalizr for Rest #457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1b057fc
feat(api): fixlets
machour Oct 9, 2017
f0948d0
Merge branch 'master' into multi-client-redux-middleware
machour Oct 9, 2017
0f5746d
fix(browser): Fix openInBrowser url
machour Oct 9, 2017
b710e80
fix(build): add lodash
machour Oct 9, 2017
b52977a
refactor(api): Remove useless files for clarity sake & reducer
machour Oct 10, 2017
ae00beb
refactor: group and host screens under src/screens
machour Oct 10, 2017
de4ab42
refactor: group and host screens under src/screens
machour Oct 10, 2017
83e92b5
refactor: get rid of initialOrg :-O
machour Oct 10, 2017
a24f64e
feat: No more waiting screen, mock entity attributes instead
machour Oct 10, 2017
0ab34f2
refactor: split repository-list into a dumb component
machour Oct 10, 2017
29fd81f
feat(list): add load progress indicator, adjust list margin
machour Oct 11, 2017
a7cd9e1
Merge remote-tracking branch 'upstream/master' into multi-client-redu…
machour Oct 11, 2017
82495a6
refactor: Namespace the API client
machour Oct 11, 2017
455229d
chore: not need to disable no-shadow anymore
machour Oct 11, 2017
cc41686
refactor: enum style for actions
machour Oct 11, 2017
166d6a9
refactor: Use new middleware for paged events
machour Oct 11, 2017
57e2f74
fix: Cleaning up (mostly @lex111 remarks)
machour Oct 11, 2017
440e182
Merge remote-tracking branch 'upstream/master' into multi-client-redu…
machour Oct 11, 2017
9f58286
fix: Use ListFooterComponent instead of pushing a fake element
machour Oct 12, 2017
5e29560
refactor: Remove middleware and use a proxy instead
machour Oct 12, 2017
77e40a2
chore: import lodash entirely
machour Oct 13, 2017
9c07e82
refactor: clean up withReducers()
machour Oct 13, 2017
a54da4b
refactor: Add schema helpers and use milli-seconds timestamps everywhere
machour Oct 13, 2017
2304b4b
fix: pagination/action key should be made of all pureArgs
machour Oct 13, 2017
e7a87f1
feat: add two new decorators: withCounter() and withAuth()
machour Oct 13, 2017
4703a88
Merge remote-tracking branch 'upstream/master' into multi-client-redu…
machour Oct 15, 2017
da4e6b1
refactor: add helpers for decorators
machour Oct 15, 2017
8055862
feat: make withCounter() store its computed data in store.counters
machour Oct 15, 2017
df3515f
refactor: switch notifications to the new API
machour Oct 15, 2017
1d65a0a
fix: Some naming/code clean up using Alexey reviews
machour Oct 15, 2017
8c24f81
refactor: decorators -> proxies
machour Oct 15, 2017
cafa620
Merge remote-tracking branch 'upstream/master' into multi-client-redu…
machour Oct 15, 2017
9cbabee
refactor: Move counting logic in the provider. Add abstract methods
machour Oct 16, 2017
5e576db
refactor: merge createCountProxy into createDispatchProxy
machour Oct 16, 2017
c12429b
Merge remote-tracking branch 'upstream/master' into multi-client-redu…
machour Oct 16, 2017
5c1d82e
fix: Locale & Prettier related changes
machour Oct 16, 2017
10a24ca
refactor: get the proxied client directly from api/rest
machour Oct 16, 2017
e2e9ca3
style: some code clean up from Jouderian
machour Oct 16, 2017
ac036ec
refactor: simplify client.fetch() call
machour Oct 16, 2017
34d6d28
refactor: decorators-helpers => api-helpers. More clean up in proxy
machour Oct 16, 2017
82be98a
fix: Fix several bugs with schemas, remove dumps
machour Oct 16, 2017
40429ca
test: Implement all schemas tests
machour Oct 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ class App extends Component {
{
storage: AsyncStorage,
transforms: [encryptor],
blacklist: ['user'],
blacklist: [
'counters',
'entities',
'pagination',
'errorMessage',
'user',
],
},
() => {
this.setState({ rehydrated: true });
Expand Down
373 changes: 373 additions & 0 deletions __tests__/api/rest/github/__snapshots__/schemas.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,373 @@
exports[`test normalizes events correctly 1`] = `
Object {
"entities": Object {
"events": Object {
"6723241817": Object {
"_entityUrl": false,
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"actor": "machour2",
"createdAt": 1508176374000,
"id": "6723241817",
"org": null,
"payload": Object {
"action": "created",
"comment": Object {
"author_association": "NONE",
"body": "bla",
"created_at": "2017-10-16T17:52:54Z",
"html_url": "https://github.com/machour/git-point-playground/issues/15#issuecomment-336970090",
"id": 336970090,
"issue_url": "https://api.github.com/repos/machour/git-point-playground/issues/15",
"updated_at": "2017-10-16T17:52:54Z",
"url": "https://api.github.com/repos/machour/git-point-playground/issues/comments/336970090",
"user": Object {
"avatar_url": "https://avatars0.githubusercontent.com/u/32770098?v=4",
"events_url": "https://api.github.com/users/machour2/events{/privacy}",
"followers_url": "https://api.github.com/users/machour2/followers",
"following_url": "https://api.github.com/users/machour2/following{/other_user}",
"gists_url": "https://api.github.com/users/machour2/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/machour2",
"id": 32770098,
"login": "machour2",
"organizations_url": "https://api.github.com/users/machour2/orgs",
"received_events_url": "https://api.github.com/users/machour2/received_events",
"repos_url": "https://api.github.com/users/machour2/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/machour2/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/machour2/subscriptions",
"type": "User",
"url": "https://api.github.com/users/machour2",
},
},
"issue": Object {
"assignee": null,
"assignees": Array [],
"author_association": "NONE",
"body": "",
"closed_at": null,
"comments": 0,
"comments_url": "https://api.github.com/repos/machour/git-point-playground/issues/15/comments",
"created_at": "2017-10-16T17:31:03Z",
"events_url": "https://api.github.com/repos/machour/git-point-playground/issues/15/events",
"html_url": "https://github.com/machour/git-point-playground/issues/15",
"id": 265851173,
"labels": Array [],
"labels_url": "https://api.github.com/repos/machour/git-point-playground/issues/15/labels{/name}",
"locked": false,
"milestone": null,
"number": 15,
"repository_url": "https://api.github.com/repos/machour/git-point-playground",
"state": "open",
"title": "notif",
"updated_at": "2017-10-16T17:52:54Z",
"url": "https://api.github.com/repos/machour/git-point-playground/issues/15",
"user": Object {
"avatar_url": "https://avatars0.githubusercontent.com/u/32770098?v=4",
"events_url": "https://api.github.com/users/machour2/events{/privacy}",
"followers_url": "https://api.github.com/users/machour2/followers",
"following_url": "https://api.github.com/users/machour2/following{/other_user}",
"gists_url": "https://api.github.com/users/machour2/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/machour2",
"id": 32770098,
"login": "machour2",
"organizations_url": "https://api.github.com/users/machour2/orgs",
"received_events_url": "https://api.github.com/users/machour2/received_events",
"repos_url": "https://api.github.com/users/machour2/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/machour2/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/machour2/subscriptions",
"type": "User",
"url": "https://api.github.com/users/machour2",
},
},
},
"repo": "machour/git-point-playground",
"type": "IssueCommentEvent",
},
"6723243870": Object {
"_entityUrl": false,
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"actor": "machour2",
"createdAt": 1508176399000,
"id": "6723243870",
"org": null,
"payload": Object {
"action": "created",
"comment": Object {
"author_association": "NONE",
"body": "plop",
"created_at": "2017-10-16T17:53:19Z",
"html_url": "https://github.com/machour/git-point-playground/issues/14#issuecomment-336970278",
"id": 336970278,
"issue_url": "https://api.github.com/repos/machour/git-point-playground/issues/14",
"updated_at": "2017-10-16T17:53:19Z",
"url": "https://api.github.com/repos/machour/git-point-playground/issues/comments/336970278",
"user": Object {
"avatar_url": "https://avatars0.githubusercontent.com/u/32770098?v=4",
"events_url": "https://api.github.com/users/machour2/events{/privacy}",
"followers_url": "https://api.github.com/users/machour2/followers",
"following_url": "https://api.github.com/users/machour2/following{/other_user}",
"gists_url": "https://api.github.com/users/machour2/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/machour2",
"id": 32770098,
"login": "machour2",
"organizations_url": "https://api.github.com/users/machour2/orgs",
"received_events_url": "https://api.github.com/users/machour2/received_events",
"repos_url": "https://api.github.com/users/machour2/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/machour2/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/machour2/subscriptions",
"type": "User",
"url": "https://api.github.com/users/machour2",
},
},
"issue": Object {
"assignee": null,
"assignees": Array [],
"author_association": "NONE",
"body": "",
"closed_at": null,
"comments": 1,
"comments_url": "https://api.github.com/repos/machour/git-point-playground/issues/14/comments",
"created_at": "2017-10-15T14:48:14Z",
"events_url": "https://api.github.com/repos/machour/git-point-playground/issues/14/events",
"html_url": "https://github.com/machour/git-point-playground/issues/14",
"id": 265577462,
"labels": Array [],
"labels_url": "https://api.github.com/repos/machour/git-point-playground/issues/14/labels{/name}",
"locked": false,
"milestone": null,
"number": 14,
"repository_url": "https://api.github.com/repos/machour/git-point-playground",
"state": "open",
"title": "more test",
"updated_at": "2017-10-16T17:53:19Z",
"url": "https://api.github.com/repos/machour/git-point-playground/issues/14",
"user": Object {
"avatar_url": "https://avatars0.githubusercontent.com/u/32770098?v=4",
"events_url": "https://api.github.com/users/machour2/events{/privacy}",
"followers_url": "https://api.github.com/users/machour2/followers",
"following_url": "https://api.github.com/users/machour2/following{/other_user}",
"gists_url": "https://api.github.com/users/machour2/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/machour2",
"id": 32770098,
"login": "machour2",
"organizations_url": "https://api.github.com/users/machour2/orgs",
"received_events_url": "https://api.github.com/users/machour2/received_events",
"repos_url": "https://api.github.com/users/machour2/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/machour2/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/machour2/subscriptions",
"type": "User",
"url": "https://api.github.com/users/machour2",
},
},
},
"repo": "machour/git-point-playground",
"type": "IssueCommentEvent",
},
},
"repos": Object {
"machour/git-point-playground": Object {
"_entityUrl": "https://github.com/machour/git-point-playground",
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"fullName": "machour/git-point-playground",
"id": "machour/git-point-playground",
"shortName": "git-point-playground",
},
},
"users": Object {
"machour2": Object {
"_entityUrl": false,
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"avatarUrl": "https://avatars.githubusercontent.com/u/32770098?",
"id": "machour2",
"login": "machour2",
},
},
},
"result": Array [
"6723243870",
"6723241817",
],
}
`;

exports[`test normalizes notifications correctly 1`] = `
Object {
"entities": Object {
"notifications": Object {
"266802681": Object {
"_entityUrl": false,
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"id": "266802681",
"link": "https://api.github.com/repos/machour/git-point-playground/issues/14",
"reason": "subscribed",
"repo": "machour/git-point-playground",
"title": "more test",
"type": "Issue",
"unread": true,
"updatedAt": 1508176400000,
},
"267118003": Object {
"_entityUrl": false,
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"id": "267118003",
"link": "https://api.github.com/repos/machour/git-point-playground/issues/15",
"reason": "subscribed",
"repo": "machour/git-point-playground",
"title": "notif",
"type": "Issue",
"unread": true,
"updatedAt": 1508176376000,
},
},
"repos": Object {
"machour/git-point-playground": Object {
"_entityUrl": "https://github.com/machour/git-point-playground",
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"description": null,
"fullName": "machour/git-point-playground",
"id": "machour/git-point-playground",
"orgOwner": false,
"private": false,
"shortName": "git-point-playground",
"userOwner": "machour",
},
},
"users": Object {
"machour": Object {
"_entityUrl": false,
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"avatarUrl": "https://avatars2.githubusercontent.com/u/304450?v=4",
"id": "machour",
"login": "machour",
},
},
},
"result": Array [
"266802681",
"267118003",
],
}
`;

exports[`test normalizes org correctly 1`] = `
Object {
"entities": Object {
"orgs": Object {
"gitpoint": Object {
"_entityUrl": "https://github.com/gitpoint",
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": true,
"avatarUrl": "https://avatars0.githubusercontent.com/u/30082377?v=4&updatedAt=1501807857000",
"countPrivateRepos": 0,
"countPublicRepos": 2,
"countRepos": 2,
"createdAt": 1499788147000,
"description": "An open source GitHub client for iOS and Android. Built with React Native :iphone:",
"id": "gitpoint",
"location": "Toronto",
"login": "gitpoint",
"name": "GitPoint",
"updatedAt": 1501807857000,
"webSite": "https://gitpoint.co",
},
},
},
"result": "gitpoint",
}
`;

exports[`test normalizes repo correctly 1`] = `
Object {
"entities": Object {
"orgs": Object {
"gitpoint": Object {
"_entityUrl": "https://github.com/gitpoint",
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"avatarUrl": "https://avatars0.githubusercontent.com/u/30082377?v=4",
"id": "gitpoint",
"login": "gitpoint",
},
},
"repos": Object {
"gitpoint/git-point": Object {
"_entityUrl": "https://github.com/gitpoint/git-point",
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": false,
"countForks": 224,
"countOpenIssues": 93,
"countStargazzers": 2501,
"countWatchers": 2501,
"defaultBranch": "master",
"description": "GitHub in your pocket :iphone:",
"fullName": "gitpoint/git-point",
"hasIssues": true,
"id": "gitpoint/git-point",
"language": "JavaScript",
"orgOwner": "gitpoint",
"private": false,
"shortName": "git-point",
"userOwner": false,
},
},
},
"result": "gitpoint/git-point",
}
`;

exports[`test normalizes user correctly 1`] = `
Object {
"entities": Object {
"users": Object {
"machour": Object {
"_entityUrl": "https://github.com/machour",
"_fetchedAt": 1508189841664,
"_isAuth": false,
"_isComplete": true,
"avatarUrl": "https://avatars2.githubusercontent.com/u/304450?v=4&updatedAt=1507576478000",
"bio": null,
"company": "IDK",
"countFollowers": 65,
"countFollowing": 43,
"countPrivateRepos": 0,
"countPublicRepos": 56,
"countRepos": 56,
"createdAt": 1276477765000,
"fullName": "Mehdi Achour",
"id": "machour",
"location": "Tunis",
"login": "machour",
"updatedAt": 1507576478000,
"webSite": "https://machour.idk.tn/",
},
},
},
"result": "machour",
}
`;
Loading