Skip to content

Commit

Permalink
Fix filters not being fetched on initial page load
Browse files Browse the repository at this point in the history
We should also be refetching filters when we open
a new table anyway.
  • Loading branch information
Arnei committed Jan 23, 2025
1 parent 2d3e5fe commit 8878c28
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 51 deletions.
7 changes: 1 addition & 6 deletions src/components/configuration/Themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import MainView from "../MainView";
import Footer from "../Footer";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchThemes } from "../../slices/themeSlice";

Expand All @@ -28,8 +27,6 @@ const Themes = () => {
const { t } = useTranslation();
const dispatch = useAppDispatch();

const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));

const [displayNavigation, setNavigation] = useState(false);
const [displayNewThemesModal, setNewThemesModal] = useState(false);

Expand All @@ -45,9 +42,7 @@ const Themes = () => {
};

useEffect(() => {
if ("themes" !== currentFilterType) {
dispatch(fetchFilters("themes"));
}
dispatch(fetchFilters("themes"));

// Reset text filter
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/events/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { useHotkeys } from "react-hotkeys-hook";
import { availableHotkeys } from "../../configs/hotkeysConfig";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { fetchAssetUploadOptions } from "../../thunks/assetsThunks";
import { useAppDispatch, useAppSelector } from "../../store";
import {
Expand All @@ -54,7 +53,6 @@ const Events = () => {
const { t } = useTranslation();
const dispatch = useAppDispatch();

const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));
const displayEventDetailsModal = useAppSelector(state => showModal(state));

const [displayActionMenu, setActionMenu] = useState(false);
Expand Down Expand Up @@ -100,9 +98,7 @@ const Events = () => {
};

useEffect(() => {
if ("events" !== currentFilterType) {
dispatch(fetchFilters("events"))
}
dispatch(fetchFilters("events"))

// Reset text filter
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/events/Series.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Footer from "../Footer";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { availableHotkeys } from "../../configs/hotkeysConfig";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { useHotkeys } from "react-hotkeys-hook";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchEvents } from "../../slices/eventSlice";
Expand All @@ -50,7 +49,6 @@ const Series = () => {
const [displayDeleteSeriesModal, setDeleteSeriesModal] = useState(false);

const user = useAppSelector(state => getUserInformation(state));
const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));

let location = useLocation();

Expand Down Expand Up @@ -80,9 +78,7 @@ const Series = () => {
};

useEffect(() => {
if ("series" !== currentFilterType) {
dispatch(fetchFilters("series"))
}
dispatch(fetchFilters("series"))

// Reset text filer
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/recordings/Recordings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import MainView from "../MainView";
import Footer from "../Footer";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchRecordings } from "../../slices/recordingSlice";
import { AsyncThunk } from "@reduxjs/toolkit";
Expand All @@ -31,7 +30,6 @@ const Recordings = () => {
const [displayNavigation, setNavigation] = useState(false);

const user = useAppSelector(state => getUserInformation(state));
const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));
const recordings = useAppSelector(state => getTotalRecordings(state));

const loadRecordings = async () => {
Expand All @@ -43,9 +41,7 @@ const Recordings = () => {
};

useEffect(() => {
if ("recordings" !== currentFilterType) {
dispatch(fetchFilters("recordings"));
}
dispatch(fetchFilters("recordings"));

// Reset text filter
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/systems/Jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import MainView from "../MainView";
import Footer from "../Footer";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchJobs } from "../../slices/jobSlice";
import { fetchServers } from "../../slices/serverSlice";
Expand All @@ -35,7 +34,6 @@ const Jobs = () => {
const dispatch = useAppDispatch();
const [displayNavigation, setNavigation] = useState(false);

const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));
const user = useAppSelector(state => getUserInformation(state));
const jobs = useAppSelector(state => getTotalJobs(state));

Expand Down Expand Up @@ -70,9 +68,7 @@ const Jobs = () => {
};

useEffect(() => {
if ("jobs" !== currentFilterType) {
dispatch(fetchFilters("jobs"));
}
dispatch(fetchFilters("jobs"));

// Reset text filter
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/systems/Servers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import MainView from "../MainView";
import Footer from "../Footer";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchServices } from "../../slices/serviceSlice";
import { fetchJobs } from "../../slices/jobSlice";
Expand All @@ -35,7 +34,6 @@ const Servers = () => {
const dispatch = useAppDispatch();
const [displayNavigation, setNavigation] = useState(false);

const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));
const user = useAppSelector(state => getUserInformation(state));
const servers = useAppSelector(state => getTotalServers(state));

Expand Down Expand Up @@ -70,9 +68,7 @@ const Servers = () => {
};

useEffect(() => {
if ("servers" !== currentFilterType) {
dispatch(fetchFilters("servers"));
}
dispatch(fetchFilters("servers"));

// Reset text filter
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/systems/Services.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import MainView from "../MainView";
import Footer from "../Footer";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchServers } from "../../slices/serverSlice";
import { fetchJobs } from "../../slices/jobSlice";
Expand All @@ -34,7 +33,6 @@ const Services = () => {
const dispatch = useAppDispatch();
const [displayNavigation, setNavigation] = useState(false);

const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));
const user = useAppSelector(state => getUserInformation(state));
const services = useAppSelector(state => getTotalServices(state));

Expand Down Expand Up @@ -69,9 +67,7 @@ const Services = () => {
};

useEffect(() => {
if ("services" !== currentFilterType) {
dispatch(fetchFilters("services"));
}
dispatch(fetchFilters("services"));

// Reset text filter
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/users/Acls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import MainView from "../MainView";
import Footer from "../Footer";
import { hasAccess } from "../../utils/utils";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchAcls } from "../../slices/aclSlice";
import { fetchUsers } from "../../slices/userSlice";
Expand All @@ -39,7 +38,6 @@ const Acls: React.FC = () => {
const dispatch = useAppDispatch();
const acls = useAppSelector(state => getTotalAcls(state));
const user = useAppSelector(state => getUserInformation(state));
const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));

const loadAcls = async () => {
// Fetching acls from server
Expand Down Expand Up @@ -72,9 +70,7 @@ const Acls: React.FC = () => {
};

useEffect(() => {
if ("acls" !== currentFilterType) {
dispatch(fetchFilters("acls"));
}
dispatch(fetchFilters("acls"));

// Reset text filter
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/users/Groups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import MainView from "../MainView";
import Footer from "../Footer";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { fetchAcls } from "../../slices/aclSlice";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchUsers } from "../../slices/userSlice";
Expand All @@ -39,7 +38,6 @@ const Groups = () => {

const user = useAppSelector(state => getUserInformation(state));
const groups = useAppSelector(state => getTotalGroups(state));
const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));

const loadGroups = async () => {
// Fetching groups from server
Expand Down Expand Up @@ -72,9 +70,7 @@ const Groups = () => {
};

useEffect(() => {
if ("groups" !== currentFilterType) {
dispatch(fetchFilters("groups"));
}
dispatch(fetchFilters("groups"));

// Reset text filter
dispatch(editTextFilter(""));
Expand Down
6 changes: 1 addition & 5 deletions src/components/users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import MainView from "../MainView";
import Footer from "../Footer";
import { getUserInformation } from "../../selectors/userInfoSelectors";
import { hasAccess } from "../../utils/utils";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { fetchAcls } from "../../slices/aclSlice";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchUsers } from "../../slices/userSlice";
Expand All @@ -39,7 +38,6 @@ const Users: React.FC = () => {

const users = useAppSelector(state => getTotalUsers(state));
const user = useAppSelector(state => getUserInformation(state));
const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));

const loadUsers = async () => {
// Fetching users from server
Expand Down Expand Up @@ -72,9 +70,7 @@ const Users: React.FC = () => {
};

useEffect(() => {
if ("users" !== currentFilterType) {
dispatch(fetchFilters("users"));
}
dispatch(fetchFilters("users"));

// Reset text filter
dispatch(editTextFilter(""));
Expand Down

0 comments on commit 8878c28

Please sign in to comment.