diff --git a/web/src/components/Sidebar.tsx b/web/src/components/Sidebar.tsx index 2926175..e26fd16 100644 --- a/web/src/components/Sidebar.tsx +++ b/web/src/components/Sidebar.tsx @@ -1,12 +1,6 @@ -import { useState } from 'react'; -import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; -import { feedsApi } from '../api/feeds'; -import { AddFeedModal } from './AddFeedModal'; +import { articlesApi } from '../api/articles'; -interface SidebarProps { - onSelectFeed: (feedId: string | null) => void; - selectedFeedId: string | null; -} +// ... (existing imports) export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) { const [isAddModalOpen, setIsAddModalOpen] = useState(false); @@ -17,22 +11,22 @@ export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) { queryFn: () => feedsApi.list(), }); - const deleteFeedMutation = useMutation({ - mutationFn: (id: string) => feedsApi.delete(id), - onSuccess: (_, deletedId) => { - queryClient.invalidateQueries({ queryKey: ['feeds'] }); - if (selectedFeedId === deletedId) { - onSelectFeed(null); + const markAllReadMutation = useMutation({ + mutationFn: () => { + if (selectedFeedId) { + return articlesApi.markAllRead(selectedFeedId); } + return articlesApi.markAllReadGlobal(); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['feeds'] }); + queryClient.invalidateQueries({ queryKey: ['articles'] }); }, }); - const handleDelete = (e: React.MouseEvent, id: string) => { - e.stopPropagation(); - if (window.confirm('Voulez-vous vraiment supprimer ce flux ?')) { - deleteFeedMutation.mutate(id); - } - }; + // ... (deleteFeedMutation) + + // ... return ( <> @@ -40,8 +34,9 @@ export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) {

onSelectFeed(null)} > FlowReader

@@ -56,13 +51,23 @@ export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) {