@@ -15,9 +15,9 @@ export const loadUser = createAsyncThunk(
15
15
}
16
16
} ,
17
17
{
18
- // If the user is already cached, this thunk will not dispatch anything.
19
18
condition : ( { login, requiredFields } , { getState } ) => {
20
19
const user = getState ( ) . entities . users [ login ]
20
+ // If the user is already cached, nothing will be requested or dispatched
21
21
const shouldProceed = ! (
22
22
user && requiredFields . every ( key => user . hasOwnProperty ( key ) )
23
23
)
@@ -40,9 +40,9 @@ export const loadRepo = createAsyncThunk(
40
40
}
41
41
} ,
42
42
{
43
- // If the user is repo cached, this thunk will not dispatch anything.
44
43
condition : ( { fullName, requiredFields } , { getState } ) => {
45
44
const repo = getState ( ) . entities . repos [ fullName ]
45
+ // If the repo is cached, nothing will be requested or dispatched
46
46
const shouldProceed = ! (
47
47
repo && requiredFields . every ( key => repo . hasOwnProperty ( key ) )
48
48
)
@@ -51,8 +51,9 @@ export const loadRepo = createAsyncThunk(
51
51
}
52
52
)
53
53
54
- // Fetches a page of starred repos by a particular user.
55
- // Bails out if page is cached and user didn't specifically request next page.
54
+ /**
55
+ * Fetches a page of starred repos by a particular user.
56
+ */
56
57
export const loadStarred = createAsyncThunk (
57
58
'loadStarred' ,
58
59
async ( { login } , { rejectWithValue, getState } ) => {
@@ -66,9 +67,9 @@ export const loadStarred = createAsyncThunk(
66
67
}
67
68
} ,
68
69
{
69
- // If the user is repo cached, this thunk will not dispatch anything.
70
70
condition : ( { login, nextPage } , { getState } ) => {
71
71
const { pageCount = 0 } = getState ( ) . pagination . starredByUser [ login ] || { }
72
+ // Bails out if page is cached and user didn't specifically request next page.
72
73
const shouldProceed = ! ( pageCount > 0 && ! nextPage )
73
74
return shouldProceed
74
75
}
@@ -77,8 +78,6 @@ export const loadStarred = createAsyncThunk(
77
78
78
79
/**
79
80
* Fetches a page of stargazers for a particular repo.
80
- * Bails out if page is cached and user didn't specifically request next page.
81
- * Relies on Redux Thunk middleware.
82
81
*/
83
82
export const loadStargazers = createAsyncThunk (
84
83
'loadStargazers' ,
@@ -93,10 +92,10 @@ export const loadStargazers = createAsyncThunk(
93
92
}
94
93
} ,
95
94
{
96
- // If the user is repo cached, this thunk will not dispatch anything.
97
95
condition : ( { nextPage, fullName } , { getState } ) => {
98
96
const { pageCount = 0 } =
99
97
getState ( ) . pagination . stargazersByRepo [ fullName ] || { }
98
+ // Bails out if page is cached and user didn't specifically request next page.
100
99
const shouldProceed = ! ( pageCount > 0 && ! nextPage )
101
100
return shouldProceed
102
101
}
0 commit comments