diff --git a/src/App.jsx b/src/App.jsx index dbea16c..2c242a0 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -23,12 +23,14 @@ import Reports from "./pages/Reports"; import Login from "./pages/Login"; import AppStore from "./store"; +import { selectIsInElectron } from "./reducers/configReducer"; +import { selectCurrentUser } from "./reducers/accountReducer"; function PageRouter() { const theme = useTheme(); - const currentUser = useSelector((state) => state.accountReducer.currentUser); - const isInElectron = useSelector((state) => state.configReducer.isInElectron); + const currentUser = useSelector(selectCurrentUser); + const isInElectron = useSelector(selectIsInElectron); // when we get a jwt, set the cookie in electron React.useEffect(() => { diff --git a/src/components/Actions/CommentButtons.jsx b/src/components/Actions/CommentButtons.jsx index 19faae0..0c7bb35 100644 --- a/src/components/Actions/CommentButtons.jsx +++ b/src/components/Actions/CommentButtons.jsx @@ -15,11 +15,12 @@ import { ConfirmDialog, } from "./BaseElements.jsx"; import { getSiteData } from "../../hooks/getSiteData"; +import { selectShowResolved } from "../../reducers/configReducer.js"; export const ResolveCommentReportButton = ({ report, ...props }) => { const queryClient = useQueryClient(); - const showResolved = useSelector((state) => state.configReducer.showResolved); + const showResolved = useSelector(selectShowResolved); const { baseUrl, siteData, localPerson, userRole } = getSiteData(); const { data, callAction, isSuccess, isLoading, error } = useLemmyHttpAction("resolveCommentReport"); diff --git a/src/components/Actions/PMButtons.jsx b/src/components/Actions/PMButtons.jsx index 9c50388..c13fb4b 100644 --- a/src/components/Actions/PMButtons.jsx +++ b/src/components/Actions/PMButtons.jsx @@ -15,13 +15,14 @@ import { ConfirmDialog, } from "./BaseElements.jsx"; import { getSiteData } from "../../hooks/getSiteData"; +import { selectShowResolved } from "../../reducers/configReducer.js"; // allow resolving / unresolving a post report // resolvePrivateMessageReport export const ResolvePMReportButton = ({ report, ...props }) => { const queryClient = useQueryClient(); - const showResolved = useSelector((state) => state.configReducer.showResolved); + const showResolved = useSelector(selectShowResolved); const { baseUrl, siteData, localPerson, userRole } = getSiteData(); const { data, callAction, isSuccess, isLoading, error } = useLemmyHttpAction("resolvePrivateMessageReport"); diff --git a/src/components/Actions/PostButtons.jsx b/src/components/Actions/PostButtons.jsx index 3ea776e..401550b 100644 --- a/src/components/Actions/PostButtons.jsx +++ b/src/components/Actions/PostButtons.jsx @@ -17,12 +17,13 @@ import { ConfirmDialog, } from "./BaseElements.jsx"; import { getSiteData } from "../../hooks/getSiteData"; +import { selectShowResolved } from "../../reducers/configReducer.js"; // allow resolving / unresolving a post report export const ResolvePostReportButton = ({ report, ...props }) => { const queryClient = useQueryClient(); - const showResolved = useSelector((state) => state.configReducer.showResolved); + const showResolved = useSelector(selectShowResolved); const { baseUrl, siteData, localPerson, userRole } = getSiteData(); const { data, callAction, isSuccess, isLoading, error } = useLemmyHttpAction("resolvePostReport"); diff --git a/src/components/Actions/RegistrationButtons.jsx b/src/components/Actions/RegistrationButtons.jsx index 5bcce39..f65aa2a 100644 --- a/src/components/Actions/RegistrationButtons.jsx +++ b/src/components/Actions/RegistrationButtons.jsx @@ -13,6 +13,7 @@ import { useLemmyHttpAction } from "../../hooks/useLemmyHttp.js"; import { getSiteData } from "../../hooks/getSiteData"; import { BaseActionButton, InputElement, ConfirmDialog } from "./BaseElements.jsx"; +import { selectHideReadApprovals } from "../../reducers/configReducer.js"; export const ApproveButton = ({ registration, ...props }) => { const queryClient = useQueryClient(); @@ -24,7 +25,7 @@ export const ApproveButton = ({ registration, ...props }) => { "approveRegistrationApplication", ); - const hideReadApprovals = useSelector((state) => state.configReducer.hideReadApprovals); + const hideReadApprovals = useSelector(selectHideReadApprovals); const [isConfirming, setIsConfirming] = React.useState(false); @@ -172,7 +173,7 @@ export const DenyButton = ({ registration, ...props }) => { const [confirmOpen, setConfirmOpen] = React.useState(false); const [denyReason, setDenyReason] = React.useState(""); - const hideReadApprovals = useSelector((state) => state.configReducer.hideReadApprovals); + const hideReadApprovals = useSelector(selectHideReadApprovals); React.useEffect(() => { if (isSuccess) { diff --git a/src/components/Filters.jsx b/src/components/Filters.jsx index e593b63..e58c568 100644 --- a/src/components/Filters.jsx +++ b/src/components/Filters.jsx @@ -10,14 +10,14 @@ import Checkbox from "@mui/joy/Checkbox"; import Chip from "@mui/joy/Chip"; -import { setConfigItem } from "../reducers/configReducer"; +import { selectFilterCommunity, selectFilterType, selectHideReadApprovals, selectModLogType, selectShowRemoved, selectShowResolved, setConfigItem } from "../reducers/configReducer"; import { getSiteData } from "../hooks/getSiteData"; import { getModLogTypeNames } from "../utils"; export function FilterCommunity() { const dispatch = useDispatch(); - const filterCommunity = useSelector((state) => state.configReducer.filterCommunity); + const filterCommunity = useSelector(selectFilterCommunity); const { modCommms } = getSiteData(); @@ -84,7 +84,7 @@ export function FilterCommunity() { export function FilterTypeSelect() { const dispatch = useDispatch(); - const filterType = useSelector((state) => state.configReducer.filterType); + const filterType = useSelector(selectFilterType); return (