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

fix: feed deletion #4023

Merged
merged 2 commits into from
Dec 24, 2024
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
27 changes: 19 additions & 8 deletions packages/shared/src/components/CustomFeedEmptyScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import { HashtagIcon } from './icons';
import { PageContainer } from './utilities';
import { ButtonSize } from './buttons/common';
import { webappUrl } from '../lib/constants';
import { usePlusSubscription } from '../hooks';
import { DeleteCustomFeed } from './buttons/DeleteCustomFeed';

export const CustomFeedEmptyScreen = (): ReactElement => {
const { isPlus } = usePlusSubscription();
const router = useRouter();

return (
Expand All @@ -27,14 +30,22 @@ export const CustomFeedEmptyScreen = (): ReactElement => {
Start by configuring your feed settings to tailor content to your
interests. Add tags, filters, and sources to make it truly yours.
</EmptyScreenDescription>
<EmptyScreenButton
onClick={() => {
router.push(`${webappUrl}feeds/${router.query.slugOrId}/edit`);
}}
size={ButtonSize.Large}
>
Set up feed
</EmptyScreenButton>
<div className="flex flex-col items-center gap-4 tablet:flex-row">
<EmptyScreenButton
onClick={() => {
router.push(`${webappUrl}feeds/${router.query.slugOrId}/edit`);
}}
size={ButtonSize.Large}
>
Set up feed
</EmptyScreenButton>
{!isPlus ? (
<DeleteCustomFeed
className="mt-10"
feedId={router.query.slugOrId as string}
/>
) : null}
</div>
</EmptyScreenContainer>
</PageContainer>
);
Expand Down
35 changes: 35 additions & 0 deletions packages/shared/src/components/buttons/DeleteCustomFeed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { type ReactElement } from 'react';
import { ButtonSize, ButtonVariant, type ButtonProps, Button } from './Button';
import { SimpleTooltip } from '../tooltips';
import { useFeedSettingsEdit } from '../feeds/FeedSettings/useFeedSettingsEdit';
import { TrashIcon } from '../icons';
import { WithClassNameProps } from '../utilities';

type DeleteCustomFeedProps = {
feedId: string;
} & WithClassNameProps;
export const DeleteCustomFeed = ({
feedId,
className,
}: DeleteCustomFeedProps): ReactElement => {
const { onDelete } = useFeedSettingsEdit({ feedSlugOrId: feedId });

const commonIconProps: ButtonProps<'button'> = {
size: ButtonSize.Medium,
variant: ButtonVariant.Float,
iconSecondaryOnHover: true,
className,
};

return (
<SimpleTooltip
placement="bottom"
content="Delete custom feed"
container={{
className: 'max-w-64 text-center',
}}
>
<Button {...commonIconProps} icon={<TrashIcon />} onClick={onDelete} />
</SimpleTooltip>
);
};
7 changes: 6 additions & 1 deletion packages/shared/src/components/layout/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { useAuthContext } from '../../contexts/AuthContext';
import useCustomDefaultFeed from '../../hooks/feed/useCustomDefaultFeed';
import { useLazyModal } from '../../hooks/useLazyModal';
import { LazyModal } from '../modals/common/types';
import { DeleteCustomFeed } from '../buttons/DeleteCustomFeed';

type State<T> = [T, Dispatch<SetStateAction<T>>];

Expand Down Expand Up @@ -76,7 +77,8 @@ export const SearchControlHeader = ({
const isLaptop = useViewSize(ViewSize.Laptop);
const isMobile = useViewSize(ViewSize.MobileL);
const { streak, isLoading, isStreaksEnabled } = useReadingStreak();
const { showPlusSubscription, isEnrolledNotPlus } = usePlusSubscription();
const { showPlusSubscription, isEnrolledNotPlus, isPlus } =
usePlusSubscription();
const { user } = useAuthContext();
const { isCustomDefaultFeed, defaultFeedId } = useCustomDefaultFeed();
const { openModal } = useLazyModal();
Expand Down Expand Up @@ -157,6 +159,9 @@ export const SearchControlHeader = ({
key="toggle-clickbait-shield"
/>
) : null,
!isPlus && feedName === SharedFeedPage.Custom ? (
<DeleteCustomFeed feedId={router?.query?.slugOrId as string} />
) : null,
];
const actions = actionButtons.filter((button) => !!button);

Expand Down
Loading