Skip to content

Commit

Permalink
Merge pull request #17 from bento-platform/fix/app-dispatch
Browse files Browse the repository at this point in the history
fix: useAppDispatch everywhere
  • Loading branch information
davidlougheed authored Feb 9, 2024
2 parents 88d4c25 + dbeb964 commit e8be022
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { MutableRefObject, useCallback, useEffect, useMemo } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { AnyAction } from "redux";
import { ThunkAction } from "redux-thunk";

import { useBentoAuthContext } from "./contexts";
import { Resource, makeResourceKey } from "./resources";
import { fetchResourcePermissions, refreshTokens, tokenHandoff } from "./redux/authSlice";
import { RootState } from "./redux/store";
import { RootState, useAppDispatch } from "./redux/store";
import { LS_SIGN_IN_POPUP, createAuthURL } from "./performAuth";
import { fetchOpenIdConfigurationIfNecessary } from "./redux/openIdConfigSlice";
import { getIsAuthenticated, logMissingAuthContext, makeAuthorizationHeader } from "./utils";
Expand All @@ -28,7 +28,7 @@ export const useAuthorizationHeader = () => {
};

export const useResourcePermissions = (resource: Resource, authzUrl: string) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();

const haveAuthorizationService = !!authzUrl;

Expand Down Expand Up @@ -64,7 +64,7 @@ export const useHasResourcePermission = (resource: Resource, authzUrl: string, p
};

export const useOpenIdConfig = () => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const { openIdConfigUrl } = useBentoAuthContext();

useEffect(() => {
Expand All @@ -81,7 +81,7 @@ export const useOpenIdConfig = () => {
export const useSignInPopupTokenHandoff = (
windowMessageHandler: MutableRefObject<null | MessageHandlerFunc>
) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const { applicationUrl, authCallbackUrl, clientId } = useBentoAuthContext();
useEffect(() => {
if (!applicationUrl || !authCallbackUrl || !clientId) {
Expand Down Expand Up @@ -112,7 +112,7 @@ export const useSessionWorkerTokenRefresh = (
createWorker: () => Worker,
fetchUserDependentData: ThunkAction<void, RootState, unknown, AnyAction>,
) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const { clientId } = useBentoAuthContext();

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/performAuth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { useHistory, useLocation } from "react-router-dom";
import { AnyAction } from "redux";
import { ThunkAction } from "redux-thunk";
Expand Down Expand Up @@ -85,7 +85,7 @@ export const useHandleCallback = (
authCodeCallback = undefined,
uiErrorCallback: (message: string) => void,
) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const history = useHistory();
const location = useLocation();
const { authCallbackUrl, clientId } = useBentoAuthContext();
Expand Down
6 changes: 3 additions & 3 deletions src/performSignOut.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useCallback } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";

import { useBentoAuthContext } from "./contexts";
import { useOpenIdConfig } from "./hooks";
import { RootState } from "./redux/store";
import { RootState, useAppDispatch } from "./redux/store";
import { setLSNotSignedIn } from "./performAuth";
import { signOut } from "./redux/authSlice";
import { logMissingAuthContext } from "./utils";

export const usePerformSignOut = () => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const { clientId, postSignOutUrl } = useBentoAuthContext();
const { idToken } = useSelector((state: RootState) => state.auth);
const openIdConfig = useOpenIdConfig();
Expand Down

0 comments on commit e8be022

Please sign in to comment.