Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add community blocking from feed by long press #439

Merged
merged 1 commit into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/features/inbox/messages/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ export default function Message({ message }: MessageProps) {
useIonViewWillEnter(() => setFocused(true));
useIonViewDidLeave(() => setFocused(false));

const bind = useLongPress(() => {
presentReport(message);
});
const bind = useLongPress(
() => {
presentReport(message);
},
{ cancelOnMovement: true }
);

useEffect(() => {
if (
Expand Down
35 changes: 34 additions & 1 deletion src/features/labels/links/CommunityLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import Handle from "../Handle";
import { StyledLink } from "./shared";
import ItemIcon from "../img/ItemIcon";
import { css } from "@emotion/react";
import { useAppDispatch } from "../../../store";
import { useIonActionSheet, useIonToast } from "@ionic/react";
import { useLongPress } from "use-long-press";
import { blockCommunity } from "../../community/communitySlice";
import { buildBlocked } from "../../../helpers/toastMessages";

interface CommunityLinkProps {
community: Community;
Expand All @@ -15,16 +20,44 @@ interface CommunityLinkProps {

export default function CommunityLink({
community,
className,
showInstanceWhenRemote,
className,
}: CommunityLinkProps) {
const dispatch = useAppDispatch();
const [present] = useIonActionSheet();
const [presentToast] = useIonToast();

const bind = useLongPress(
() => {
present([
{
text: "Block Community",
role: "destructive",
handler: () => {
(async () => {
await dispatch(blockCommunity(true, community.id));

presentToast(buildBlocked(true, getHandle(community)));
})();
},
},
{
text: "Cancel",
role: "cancel",
},
]);
},
{ cancelOnMovement: true }
);

const buildGeneralBrowseLink = useBuildGeneralBrowseLink();

return (
<StyledLink
to={buildGeneralBrowseLink(`/c/${getHandle(community)}`)}
onClick={(e) => e.stopPropagation()}
className={className}
{...bind()}
>
<ItemIcon
item={community}
Expand Down