@@ -8,15 +8,18 @@ export const USER_FAILURE = 'USER_FAILURE'
8
8
// Relies on the custom API middleware defined in ../middleware/api.js.
9
9
const fetchUser = login => ( {
10
10
[ CALL_API ] : {
11
- types : [ USER_REQUEST , USER_SUCCESS , USER_FAILURE ] ,
11
+ types : [ USER_REQUEST , USER_SUCCESS , USER_FAILURE ] ,
12
12
endpoint : `users/${ login } ` ,
13
13
schema : Schemas . USER
14
14
}
15
15
} )
16
16
17
17
// Fetches a single user from Github API unless it is cached.
18
18
// Relies on Redux Thunk middleware.
19
- export const loadUser = ( login , requiredFields = [ ] ) => ( dispatch , getState ) => {
19
+ export const loadUser = ( login , requiredFields = [ ] ) => (
20
+ dispatch ,
21
+ getState
22
+ ) => {
20
23
const user = getState ( ) . entities . users [ login ]
21
24
if ( user && requiredFields . every ( key => user . hasOwnProperty ( key ) ) ) {
22
25
return null
@@ -33,15 +36,18 @@ export const REPO_FAILURE = 'REPO_FAILURE'
33
36
// Relies on the custom API middleware defined in ../middleware/api.js.
34
37
const fetchRepo = fullName => ( {
35
38
[ CALL_API ] : {
36
- types : [ REPO_REQUEST , REPO_SUCCESS , REPO_FAILURE ] ,
39
+ types : [ REPO_REQUEST , REPO_SUCCESS , REPO_FAILURE ] ,
37
40
endpoint : `repos/${ fullName } ` ,
38
41
schema : Schemas . REPO
39
42
}
40
43
} )
41
44
42
45
// Fetches a single repository from Github API unless it is cached.
43
46
// Relies on Redux Thunk middleware.
44
- export const loadRepo = ( fullName , requiredFields = [ ] ) => ( dispatch , getState ) => {
47
+ export const loadRepo = ( fullName , requiredFields = [ ] ) => (
48
+ dispatch ,
49
+ getState
50
+ ) => {
45
51
const repo = getState ( ) . entities . repos [ fullName ]
46
52
if ( repo && requiredFields . every ( key => repo . hasOwnProperty ( key ) ) ) {
47
53
return null
@@ -59,7 +65,7 @@ export const STARRED_FAILURE = 'STARRED_FAILURE'
59
65
const fetchStarred = ( login , nextPageUrl ) => ( {
60
66
login,
61
67
[ CALL_API ] : {
62
- types : [ STARRED_REQUEST , STARRED_SUCCESS , STARRED_FAILURE ] ,
68
+ types : [ STARRED_REQUEST , STARRED_SUCCESS , STARRED_FAILURE ] ,
63
69
endpoint : nextPageUrl ,
64
70
schema : Schemas . REPO_ARRAY
65
71
}
@@ -69,10 +75,8 @@ const fetchStarred = (login, nextPageUrl) => ({
69
75
// Bails out if page is cached and user didn't specifically request next page.
70
76
// Relies on Redux Thunk middleware.
71
77
export const loadStarred = ( login , nextPage ) => ( dispatch , getState ) => {
72
- const {
73
- nextPageUrl = `users/${ login } /starred` ,
74
- pageCount = 0
75
- } = getState ( ) . pagination . starredByUser [ login ] || { }
78
+ const { nextPageUrl = `users/${ login } /starred` , pageCount = 0 } =
79
+ getState ( ) . pagination . starredByUser [ login ] || { }
76
80
77
81
if ( pageCount > 0 && ! nextPage ) {
78
82
return null
@@ -90,7 +94,7 @@ export const STARGAZERS_FAILURE = 'STARGAZERS_FAILURE'
90
94
const fetchStargazers = ( fullName , nextPageUrl ) => ( {
91
95
fullName,
92
96
[ CALL_API ] : {
93
- types : [ STARGAZERS_REQUEST , STARGAZERS_SUCCESS , STARGAZERS_FAILURE ] ,
97
+ types : [ STARGAZERS_REQUEST , STARGAZERS_SUCCESS , STARGAZERS_FAILURE ] ,
94
98
endpoint : nextPageUrl ,
95
99
schema : Schemas . USER_ARRAY
96
100
}
@@ -100,10 +104,8 @@ const fetchStargazers = (fullName, nextPageUrl) => ({
100
104
// Bails out if page is cached and user didn't specifically request next page.
101
105
// Relies on Redux Thunk middleware.
102
106
export const loadStargazers = ( fullName , nextPage ) => ( dispatch , getState ) => {
103
- const {
104
- nextPageUrl = `repos/${ fullName } /stargazers` ,
105
- pageCount = 0
106
- } = getState ( ) . pagination . stargazersByRepo [ fullName ] || { }
107
+ const { nextPageUrl = `repos/${ fullName } /stargazers` , pageCount = 0 } =
108
+ getState ( ) . pagination . stargazersByRepo [ fullName ] || { }
107
109
108
110
if ( pageCount > 0 && ! nextPage ) {
109
111
return null
@@ -116,5 +118,5 @@ export const RESET_ERROR_MESSAGE = 'RESET_ERROR_MESSAGE'
116
118
117
119
// Resets the currently visible error message.
118
120
export const resetErrorMessage = ( ) => ( {
119
- type : RESET_ERROR_MESSAGE
121
+ type : RESET_ERROR_MESSAGE
120
122
} )
0 commit comments