Skip to content

Commit 2000f87

Browse files
committed
Prevent making a refresh token request if plan doesnt include private access
1 parent 8a57aa8 commit 2000f87

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

packages/components/src/redux/reducers/github/installations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const githubInstallationsReducer: Reducer<State> = (
5454
draft.updatedAt = new Date().toISOString()
5555

5656
const installations = action.payload
57-
if (!(installations && installations.length)) return
57+
if (!installations) return
5858

5959
const {
6060
allIds,

packages/components/src/redux/sagas/installations.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function* init() {
3535
const isLogged = selectors.isLoggedSelector(state)
3636
if (!isLogged) continue
3737

38+
const userPlan = selectors.currentUserPlanSelector(state)
39+
3840
const lastFetchedAt = selectors.installationsLastFetchedRequestAtSelector(
3941
state,
4042
)
@@ -62,17 +64,23 @@ function* init() {
6264
})()
6365

6466
// only fetch installations tokens if:
65-
// 1. never fetched
66-
// 2. or there are expired ones
67-
// 3. or havent fetched for 50+ minutes
68-
// 4. or just installed the github app on a repo
67+
// 1. have a paid plan
68+
// 2. never fetched
69+
// 3. or there are expired ones
70+
// 4. or havent fetched for 50+ minutes
71+
// 5. or just installed the github app on a repo
6972
if (
70-
lastFetchedAt &&
7173
!(
72-
hasExpiredInstallationToken ||
73-
(fetchedNMinutesAgo && fetchedNMinutesAgo > 50)
74-
) &&
75-
!installationIdFromQuery
74+
userPlan &&
75+
(userPlan.status === 'active' || userPlan.status === 'trialing') &&
76+
userPlan.featureFlags.enablePrivateRepositories
77+
) ||
78+
(lastFetchedAt &&
79+
!(
80+
hasExpiredInstallationToken ||
81+
(fetchedNMinutesAgo && fetchedNMinutesAgo > 50)
82+
) &&
83+
!installationIdFromQuery)
7684
) {
7785
yield put(actions.refreshInstallationsNoop())
7886
continue

0 commit comments

Comments
 (0)