From 1b929f36ebecda48d4327b9598fce26151f04087 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 13 Jul 2025 16:01:51 +0900 Subject: refactor(frontend): extract FeedItem from FeedList --- frontend/src/components/FeedList.tsx | 100 ++++++----------------------------- 1 file changed, 15 insertions(+), 85 deletions(-) (limited to 'frontend/src/components/FeedList.tsx') diff --git a/frontend/src/components/FeedList.tsx b/frontend/src/components/FeedList.tsx index db12b13..d1d7bf3 100644 --- a/frontend/src/components/FeedList.tsx +++ b/frontend/src/components/FeedList.tsx @@ -1,12 +1,6 @@ -import { faCheck, faCircle, faTrash } from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { useMutation, useQuery } from "urql"; -import { - GetFeedsDocument, - MarkFeedReadDocument, - MarkFeedUnreadDocument, - UnsubscribeFeedDocument, -} from "../graphql/generated/graphql"; +import { useQuery } from "urql"; +import { GetFeedsDocument } from "../graphql/generated/graphql"; +import { FeedItem } from "./FeedItem"; interface Props { onFeedUnsubscribed?: () => void; @@ -17,89 +11,25 @@ export function FeedList({ onFeedUnsubscribed }: Props) { query: GetFeedsDocument, }); - const [, markFeedRead] = useMutation(MarkFeedReadDocument); - const [, markFeedUnread] = useMutation(MarkFeedUnreadDocument); - const [, unsubscribeFeed] = useMutation(UnsubscribeFeedDocument); - - const handleMarkAllRead = async (feedId: string) => { - await markFeedRead({ id: feedId }); - }; - - const handleMarkAllUnread = async (feedId: string) => { - await markFeedUnread({ id: feedId }); - }; - - const handleUnsubscribeFeed = async (feedId: string) => { - const confirmed = window.confirm( - "Are you sure you want to unsubscribe from this feed?", - ); - if (confirmed) { - await unsubscribeFeed({ id: feedId }); - onFeedUnsubscribed?.(); - } - }; - - if (fetching) return
Loading feeds...
; - if (error) + if (fetching) { + return
Loading feeds...
; + } + if (error) { return
Error: {error.message}
; + } if (!data?.feeds || data.feeds.length === 0) { return
No feeds added yet.
; } return (
- {data.feeds.map((feed) => { - return ( -
-
-
-

- {feed.title} -

-

- - {feed.url} - -

-
- - Last fetched: {new Date(feed.fetchedAt).toLocaleString()} - -
-
-
- - - -
-
-
- ); - })} + {data.feeds.map((feed) => ( + + ))}
); } -- cgit v1.2.3-70-g09d2