From bcccbd6a0d40fec0c22164e90784a5f99cd9bb46 Mon Sep 17 00:00:00 2001 From: Alexander Harding Date: Fri, 17 Jan 2025 12:49:12 -0600 Subject: [PATCH] fix: community actions button disabled with incorrect case (#1814) (#1815) --- src/features/community/communitySlice.ts | 10 ++++++---- src/features/community/useFetchCommunity.ts | 2 +- src/features/post/new/PostEditorModal.tsx | 2 +- src/routes/pages/shared/CommunitySidebarPage.tsx | 2 +- src/routes/pages/shared/SpecialFeedPage.tsx | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/features/community/communitySlice.ts b/src/features/community/communitySlice.ts index 70d8a05003..865c1746dc 100644 --- a/src/features/community/communitySlice.ts +++ b/src/features/community/communitySlice.ts @@ -30,8 +30,9 @@ export const communitySlice = createSlice({ initialState, reducers: { receivedCommunity: (state, action: PayloadAction) => { - state.communityByHandle[getHandle(action.payload.community)] = - action.payload; + state.communityByHandle[ + getHandle(action.payload.community).toLowerCase() + ] = action.payload; }, recievedTrendingCommunities: ( state, @@ -49,8 +50,9 @@ export const communitySlice = createSlice({ ) => { const handle = getHandle(action.payload.community_view.community); - state.communityByHandle[handle] = action.payload.community_view; - state.modsByHandle[handle] = action.payload.moderators; + state.communityByHandle[handle.toLowerCase()] = + action.payload.community_view; + state.modsByHandle[handle.toLowerCase()] = action.payload.moderators; }, }, }); diff --git a/src/features/community/useFetchCommunity.ts b/src/features/community/useFetchCommunity.ts index 878923c5bf..9c1fcbfb66 100644 --- a/src/features/community/useFetchCommunity.ts +++ b/src/features/community/useFetchCommunity.ts @@ -8,7 +8,7 @@ import { useAppDispatch, useAppSelector } from "#/store"; export default function useFetchCommunity(communityHandle: string) { const dispatch = useAppDispatch(); const community = useAppSelector( - (state) => state.community.communityByHandle[communityHandle], + (state) => state.community.communityByHandle[communityHandle.toLowerCase()], ); useEffect(() => { diff --git a/src/features/post/new/PostEditorModal.tsx b/src/features/post/new/PostEditorModal.tsx index 76cc7f7250..111775f408 100644 --- a/src/features/post/new/PostEditorModal.tsx +++ b/src/features/post/new/PostEditorModal.tsx @@ -23,7 +23,7 @@ export default function PostEditorModal({ const editOrCreateProps = typeof postOrCommunity === "string" ? { - community: communityByHandle[postOrCommunity], + community: communityByHandle[postOrCommunity.toLowerCase()], } : { existingPost: postOrCommunity, diff --git a/src/routes/pages/shared/CommunitySidebarPage.tsx b/src/routes/pages/shared/CommunitySidebarPage.tsx index d42fe63983..f1d1a13a71 100644 --- a/src/routes/pages/shared/CommunitySidebarPage.tsx +++ b/src/routes/pages/shared/CommunitySidebarPage.tsx @@ -35,7 +35,7 @@ const CommunitySidebarPageContent = memo(function CommunitySidebarPageContent({ const dispatch = useAppDispatch(); const communityView = useAppSelector( - (state) => state.community.communityByHandle[community], + (state) => state.community.communityByHandle[community.toLowerCase()], ); const mods = useAppSelector( (state) => state.community.modsByHandle[community], diff --git a/src/routes/pages/shared/SpecialFeedPage.tsx b/src/routes/pages/shared/SpecialFeedPage.tsx index 6c61a039ab..3e76f7bb19 100644 --- a/src/routes/pages/shared/SpecialFeedPage.tsx +++ b/src/routes/pages/shared/SpecialFeedPage.tsx @@ -80,7 +80,8 @@ export default function SpecialFeedPage({ type }: SpecialFeedProps) { function filterSubscribedFn(item: PostCommentItem) { if (item.post.featured_community || item.post.featured_local) return true; - const potentialCommunity = communityByHandle[getHandle(item.community)]; + const potentialCommunity = + communityByHandle[getHandle(item.community).toLowerCase()]; if (potentialCommunity) return potentialCommunity.subscribed === "NotSubscribed";