import { t, Trans } from "@lingui/macro" import { Anchor, Box, Button, Code, Container, Divider, Group, Input, NumberInput, Stack, Text, TextInput, Title } from "@mantine/core" import { useForm } from "@mantine/form" import { openConfirmModal } from "@mantine/modals" import { client, errorsToStrings } from "app/client" import { redirectToRootCategory, redirectToSelectedSource } from "app/slices/redirect" import { reloadTree } from "app/slices/tree" import { useAppDispatch, useAppSelector } from "app/store" import { FeedModificationRequest } from "app/types" import { Alert } from "components/Alert" import { CategorySelect } from "components/content/add/CategorySelect" import { Loader } from "components/Loader" import { RelativeDate } from "components/RelativeDate" import { useEffect } from "react" import { useAsync } from "react-async-hook" import { TbDeviceFloppy, TbTrash } from "react-icons/tb" import { useParams } from "react-router-dom" import useMutation from "use-mutation" function FilteringExpressionDescription() { const example = url.contains('youtube') or (author eq 'athou' and title.contains('github') return (
If not empty, an expression evaluating to 'true' or 'false'. If false, new entries for this feed will be marked as read automatically.
Available variables are 'title', 'content', 'url' 'author' and 'categories' and their content is converted to lower case to ease string comparison.
Example: {example}.
Complete available syntax is available here .
) } export function FeedDetailsPage() { const { id } = useParams() if (!id) throw Error("id required") const apiKey = useAppSelector(state => state.user.profile?.apiKey) const dispatch = useAppDispatch() const query = useAsync(() => client.feed.get(id), [id]) const feed = query.result?.data const form = useForm() const { setValues } = form const [modify, modifyResult] = useMutation(client.feed.modify, { onSuccess: () => { dispatch(reloadTree()) dispatch(redirectToSelectedSource()) }, }) const [unsubscribe, unsubscribeResult] = useMutation(client.feed.unsubscribe, { onSuccess: () => { dispatch(reloadTree()) dispatch(redirectToRootCategory()) }, }) const errors = errorsToStrings([modifyResult.error, unsubscribeResult.error]) const openUnsubscribeModal = () => { const feedName = feed?.name return openConfirmModal({ title: t`Unsubscribe`, children: ( Are you sure you want to unsubscribe from {feedName}? ), labels: { confirm: t`Confirm`, cancel: t`Cancel` }, confirmProps: { color: "red" }, onConfirm: () => unsubscribe({ id: +id }), }) } useEffect(() => { if (!feed) return setValues(feed) }, [setValues, feed]) if (!feed) return return ( {errors.length > 0 && ( )}
{feed.name} {feed.feedUrl} {feed.feedLink} {feed.message ?? t`N/A`} {apiKey && ( Link )} {!apiKey && Generate an API key in your profile first.} } {...form.getInputProps("filter")} />
) }