Skip to content

Commit

Permalink
fix: block community toast showing wrong message (#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding authored Dec 1, 2024
1 parent 283057d commit 4a9c031
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/features/community/useCommunityActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { checkIsMod, getHandle as useGetHandle } from "#/helpers/lemmy";
import { useBuildGeneralBrowseLink } from "#/helpers/routes";
import {
allNSFWHidden,
buildBlocked,
buildBlockedCommunity,
buildFavorited,
buildProblemSubscribing,
buildSuccessSubscribing,
Expand Down Expand Up @@ -161,7 +161,7 @@ export default function useCommunityActions(
handler: () => {
(async () => {
await _block();
presentToast(buildBlocked(!isBlocked));
presentToast(buildBlockedCommunity(!isBlocked));
})();
},
},
Expand All @@ -175,7 +175,7 @@ export default function useCommunityActions(
db.setSetting("has_presented_block_nsfw_tip", true);
} else {
await _block();
presentToast(buildBlocked(!isBlocked));
presentToast(buildBlockedCommunity(!isBlocked));
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/features/user/usePresentUserActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { PageContext } from "#/features/auth/PageContext";
import { getHandle } from "#/helpers/lemmy";
import { getBlockUserErrorMessage } from "#/helpers/lemmyErrors";
import { useBuildGeneralBrowseLink } from "#/helpers/routes";
import { buildBlocked } from "#/helpers/toastMessages";
import { buildBlockedUser } from "#/helpers/toastMessages";
import useAppToast from "#/helpers/useAppToast";
import { useOptimizedIonRouter } from "#/helpers/useOptimizedIonRouter";
import store, { useAppDispatch, useAppSelector } from "#/store";
Expand Down Expand Up @@ -99,7 +99,7 @@ export default function usePresentUserActions() {
throw error;
}

presentToast(buildBlocked(!isBlocked));
presentToast(buildBlockedUser(!isBlocked));
})();
},
},
Expand Down
9 changes: 8 additions & 1 deletion src/helpers/toastMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,20 @@ export const problemFetchingTitle: AppToastOptions = {
color: "warning",
};

export function buildBlocked(blocked: boolean): AppToastOptions {
export function buildBlockedUser(blocked: boolean): AppToastOptions {
return {
...shortSuccessDefaults,
message: `User ${blocked ? "blocked" : "unblocked"}!`,
};
}

export function buildBlockedCommunity(blocked: boolean): AppToastOptions {
return {
...shortSuccessDefaults,
message: `Community ${blocked ? "blocked" : "unblocked"}!`,
};
}

export function buildProblemSubscribing(
isSubscribed: boolean,
): AppToastOptions {
Expand Down

0 comments on commit 4a9c031

Please sign in to comment.