Skip to content

Commit ff1acf4

Browse files
committed
Type fixes
1 parent 3af1efa commit ff1acf4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/pages/index.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function Home({ clientId }: HomeProps): ReactElement {
7575
if (authenticated > AuthenticationType.NotAuthorized) return;
7676
console.log("Authenticating...");
7777

78-
let oAuthData: OAuth2;
78+
let oAuthData: OAuth2 | null = null;
7979
try {
8080
const oauthDataStorage = window.localStorage.getItem("github-oauth-data");
8181
if (oauthDataStorage) oAuthData = JSON.parse(oauthDataStorage);
@@ -100,7 +100,7 @@ export default function Home({ clientId }: HomeProps): ReactElement {
100100
return;
101101
}
102102

103-
if (code?.length > 0 && state?.length > 0) {
103+
if (code && code.length > 0 && state && state.length > 0) {
104104
setAuthenticated(AuthenticationType.Authenticating);
105105
console.log("Using code and state:", code, state);
106106
(async () => {
@@ -141,7 +141,7 @@ export default function Home({ clientId }: HomeProps): ReactElement {
141141
console.log("Generating authorize URL:", url);
142142
setAuthorizeUrl(url);
143143
}
144-
}, [clientId, code, state]);
144+
}, [authenticated, clientId, code, router, setAuth, state]);
145145

146146
useEffect(() => {
147147
console.log("Authenticated:", authenticated);
@@ -159,11 +159,13 @@ export default function Home({ clientId }: HomeProps): ReactElement {
159159
}
160160
setViewerData(data.viewer);
161161
})();
162-
}, [authenticated]);
162+
}, [auth, authenticated, setViewerData]);
163163

164164
useEffect(() => {
165165
if (authenticated !== AuthenticationType.Authenticated) return;
166-
let type: string, owner: string, repository: string;
166+
let type: string | null = null,
167+
owner: string | null = null,
168+
repository: string | null = null;
167169
const currentRepositoryStr =
168170
window.localStorage.getItem("currentRepository");
169171
if (!currentRepositoryStr) return;
@@ -203,7 +205,7 @@ export default function Home({ clientId }: HomeProps): ReactElement {
203205
}
204206
setUserData(data.user);
205207
});
206-
}, [authenticated]);
208+
}, [authenticated, setRepositoryData, setUserData]);
207209

208210
const daysSince = useMemo<number>(() => {
209211
const firstDate = moment().subtract(1, "month").startOf("month").toDate();
@@ -215,7 +217,9 @@ export default function Home({ clientId }: HomeProps): ReactElement {
215217
return daysSince;
216218
}, []);
217219

218-
const issuesByDay = useMemo<Array<{ date: string; Issues: number }>>(() => {
220+
const issuesByDay = useMemo<
221+
Array<{ date: string; Issues: number }> | undefined
222+
>(() => {
219223
if (!daysSince) return undefined;
220224
if (!repositoryData) return undefined;
221225
const issues = [];
@@ -237,7 +241,7 @@ export default function Home({ clientId }: HomeProps): ReactElement {
237241
}, [daysSince, repositoryData]);
238242

239243
const pullRequestsByDay = useMemo<
240-
Array<{ date: string; "Pull Requests": number }>
244+
Array<{ date: string; "Pull Requests": number }> | undefined
241245
>(() => {
242246
if (!daysSince) return undefined;
243247
if (!repositoryData) return undefined;

0 commit comments

Comments
 (0)