Skip to content

Commit

Permalink
fix: community actions button disabled with incorrect case (#1814) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding authored Jan 17, 2025
1 parent 8173e16 commit bcccbd6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/features/community/communitySlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export const communitySlice = createSlice({
initialState,
reducers: {
receivedCommunity: (state, action: PayloadAction<CommunityView>) => {
state.communityByHandle[getHandle(action.payload.community)] =
action.payload;
state.communityByHandle[
getHandle(action.payload.community).toLowerCase()
] = action.payload;
},
recievedTrendingCommunities: (
state,
Expand All @@ -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;
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/features/community/useFetchCommunity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/features/post/new/PostEditorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function PostEditorModal({
const editOrCreateProps =
typeof postOrCommunity === "string"
? {
community: communityByHandle[postOrCommunity],
community: communityByHandle[postOrCommunity.toLowerCase()],
}
: {
existingPost: postOrCommunity,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/pages/shared/CommunitySidebarPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
3 changes: 2 additions & 1 deletion src/routes/pages/shared/SpecialFeedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down

0 comments on commit bcccbd6

Please sign in to comment.