@@ -28,9 +28,14 @@ type Error = {
28
28
29
29
type Name = string ;
30
30
type ErrorMap = Record < Name , Error > ;
31
+ type GithubStarsAPIResponse = {
32
+ stargazers_count : number ;
33
+ } ;
31
34
export type SerializableDateRange = [ string , string ] ;
32
35
export type NetworkType = 'slow-2g' | '2g' | '3g' | '4g' ;
33
36
37
+ const githubRepoApiUrl = `https://api.github.com/repos/middlewarehq/middleware` ;
38
+
34
39
// This state contains things that will generally be persisted to localStorage
35
40
type State = StateFetchConfig < {
36
41
networkType : NetworkType ;
@@ -51,6 +56,7 @@ type State = StateFetchConfig<{
51
56
lastDisabledImageUpdateBannerAt : DateString | null ;
52
57
latestImageStatus : ImageStatusApiResponse | null ;
53
58
selectedIndustry : Industries ;
59
+ githubRepoStarsCount : number | null ;
54
60
} > ;
55
61
56
62
export const DEFAULT_PR_TABLE_COLUMN_STATE_MAP = {
@@ -91,7 +97,8 @@ const initialState: State = {
91
97
lastSyncedAt : null ,
92
98
lastDisabledImageUpdateBannerAt : null ,
93
99
latestImageStatus : null ,
94
- selectedIndustry : Industries . ALL_INDUSTRIES
100
+ selectedIndustry : Industries . ALL_INDUSTRIES ,
101
+ githubRepoStarsCount : null
95
102
} ;
96
103
97
104
export const appSlice = createSlice ( {
@@ -244,6 +251,14 @@ export const appSlice = createSlice({
244
251
}
245
252
}
246
253
) ;
254
+ addFetchCasesToReducer (
255
+ builder ,
256
+ getGithubRepoStars ,
257
+ 'githubRepoStarsCount' ,
258
+ ( state , action ) => {
259
+ state . githubRepoStarsCount = action . payload ;
260
+ }
261
+ ) ;
247
262
}
248
263
} ) ;
249
264
@@ -275,6 +290,15 @@ export const updateTeamBranchesMap = createAsyncThunk(
275
290
}
276
291
) ;
277
292
293
+ export const getGithubRepoStars = createAsyncThunk (
294
+ 'app/getGithubRepoStars' ,
295
+ async ( ) => {
296
+ const res = await fetch ( githubRepoApiUrl ) ;
297
+ const data : GithubStarsAPIResponse = await res . json ( ) ;
298
+ return data . stargazers_count ;
299
+ }
300
+ ) ;
301
+
278
302
const getSelectedTeam = (
279
303
selectedTeam : State [ 'singleTeam' ] ,
280
304
allTeams : State [ 'allTeams' ]
0 commit comments