Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion gatsby/onInitialClientRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export const onInitialClientRender = () => {

store.dispatch({ type: "setGapi", gapi })
store.dispatch({ type: "gapiStatus", status: "initialized" })
store.dispatch({ type: "setGoogle", google })
store.dispatch({ type: "setTokenClient", tokenClient })
})
.catch(e => {
Expand Down
6 changes: 1 addition & 5 deletions gatsby/wrapRootElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import {PartialDeep} from 'type-fest';

type State =
{
token?: {},
token?: { },
gapi?: PartialDeep<typeof gapi>,
google?: any,
tokenClient?: any,
toast?: string,
gapiStatus?: string
Expand All @@ -29,7 +28,6 @@ type State =
type Action =
| { type: 'setToken', token: {} | undefined }
| { type: 'setGapi', gapi: PartialDeep<typeof gapi> | undefined }
| { type: 'setGoogle', google: any }
| { type: 'setTokenClient', tokenClient: any }
| { type: 'setToast', toast: string | undefined }
| { type: 'gapiStatus', status: string | undefined };
Expand All @@ -39,8 +37,6 @@ const reducer = (state: State = {}, action: Action) => {
return { ...state, token: action.token }
case "setGapi":
return { ...state, gapi: action.gapi }
case "setGoogle":
return { ...state, google: action.google }
case "setTokenClient":
return { ...state, tokenClient: action.tokenClient }
case "setToast":
Expand Down
14 changes: 4 additions & 10 deletions src/components/Layout/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const useLogin = (): Requestable<Successful, {}, InProgress, Failed> => {
const gapi = useSelector((state: AppState) => state.gapi)
const gapiStatus = useSelector((state: AppState) => state.gapiStatus)
const tokenClient = useSelector((state: AppState) => state.tokenClient)
const google = useSelector((state: AppState) => state.google)
const dispatch = useDispatch()
const userStatus = token ? UserStatus.SignedIn : UserStatus.SignedOut

Expand All @@ -36,15 +35,10 @@ const useLogin = (): Requestable<Successful, {}, InProgress, Failed> => {
}, [tokenClient])

const logout = useCallback(() => {
const token = gapi?.client.getToken()
if (token && google) {
google.accounts.oauth2.revoke(token.access_token, () => {
gapi?.client.setToken(null)
dispatch({ type: "setToken", token: undefined })
localStorage.removeItem("google_token")
})
}
}, [gapi, google, dispatch])
gapi?.client.setToken(null)
dispatch({ type: "setToken", token: undefined })
localStorage.removeItem("google_token")
}, [gapi, dispatch])

useEffect(() => {
if (gapiStatus === "cannot initialize") {
Expand Down
1 change: 0 additions & 1 deletion src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ declare interface AppState {
gapiStatus?: string
measurementID: string
tokenClient?: any
google?: typeof google
}
Loading