Skip to content

Commit

Permalink
Remove useAppDispatch from tableThunks.ts
Browse files Browse the repository at this point in the history
Those thunks are likely passed to a `useReducer` somewhere,
so we can't have hooks here. We will still want to use useAppDispatch
here eventually, but it can wait until we modernized everything else
and can finally get to the tables.
  • Loading branch information
Arnei committed Dec 21, 2023
1 parent e9ea611 commit 4c4e032
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/src/thunks/tableThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import { setGroupColumns } from "../actions/groupActions";
import { fetchAcls, setAclColumns } from "../slices/aclSlice";
import { setThemeColumns } from "../actions/themeActions";
import { setServicesColumns } from "../actions/serviceActions";
import { useAppDispatch } from "../store";

/**
* This file contains methods/thunks used to manage the table in the main view and its state changes
Expand Down Expand Up @@ -407,7 +406,6 @@ export const loadThemesIntoTable = () => (dispatch, getState) => {
// Navigate between pages
// @ts-expect-error TS(7006): Parameter 'pageNumber' implicitly has an 'any' typ... Remove this comment to see the full error message
export const goToPage = (pageNumber) => async (dispatch, getState) => {
const appDispatch = useAppDispatch();
dispatch(deselectAll());
dispatch(setOffset(pageNumber));

Expand Down Expand Up @@ -462,7 +460,7 @@ export const goToPage = (pageNumber) => async (dispatch, getState) => {
break;
}
case "acls": {
await appDispatch(fetchAcls());
await dispatch(fetchAcls());
dispatch(loadAclsIntoTable());
break;
}
Expand All @@ -477,7 +475,6 @@ export const goToPage = (pageNumber) => async (dispatch, getState) => {
// Update pages for example if page size was changed
// @ts-expect-error TS(7006): Parameter 'dispatch' implicitly has an 'any' type.
export const updatePages = () => async (dispatch, getState) => {
const appDispatch = useAppDispatch();
const state = getState();

const pagination = getTablePagination(state);
Expand Down Expand Up @@ -534,7 +531,7 @@ export const updatePages = () => async (dispatch, getState) => {
break;
}
case "acls": {
await appDispatch(fetchAcls());
await dispatch(fetchAcls());
dispatch(loadAclsIntoTable());
break;
}
Expand Down

0 comments on commit 4c4e032

Please sign in to comment.