feat(ui): replace 'see all' button with 'mark all as read' action

This commit is contained in:
Antigravity Agent committed 2026-02-04 22:01:04 +01:00
1 parent 2a1ca288fb
commit ccaddce4bb
1 file changed
+31 -26
+31 -26
View File
@@ -1,12 +1,6 @@
import { useState } from 'react'; import { articlesApi } from '../api/articles';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { feedsApi } from '../api/feeds';
import { AddFeedModal } from './AddFeedModal';
interface SidebarProps { // ... (existing imports)
onSelectFeed: (feedId: string | null) => void;
selectedFeedId: string | null;
}
export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) { export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) {
const [isAddModalOpen, setIsAddModalOpen] = useState(false); const [isAddModalOpen, setIsAddModalOpen] = useState(false);
@@ -17,22 +11,22 @@ export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) {
queryFn: () => feedsApi.list(), queryFn: () => feedsApi.list(),
}); });
const deleteFeedMutation = useMutation({ const markAllReadMutation = useMutation({
mutationFn: (id: string) => feedsApi.delete(id), mutationFn: () => {
onSuccess: (_, deletedId) => { if (selectedFeedId) {
queryClient.invalidateQueries({ queryKey: ['feeds'] }); return articlesApi.markAllRead(selectedFeedId);
if (selectedFeedId === deletedId) {
onSelectFeed(null);
} }
return articlesApi.markAllReadGlobal();
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['feeds'] });
queryClient.invalidateQueries({ queryKey: ['articles'] });
}, },
}); });
const handleDelete = (e: React.MouseEvent, id: string) => { // ... (deleteFeedMutation)
e.stopPropagation();
if (window.confirm('Voulez-vous vraiment supprimer ce flux ?')) { // ...
deleteFeedMutation.mutate(id);
}
};
return ( return (
<> <>
@@ -40,8 +34,9 @@ export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) {
<div className="p-8 pb-4"> <div className="p-8 pb-4">
<div className="flex items-center justify-between mb-8"> <div className="flex items-center justify-between mb-8">
<h1 <h1
className="text-gold text-3xl font-serif italic tracking-tight" className="text-gold text-3xl font-serif italic tracking-tight cursor-pointer hover:opacity-80 transition-opacity"
style={{ textShadow: '1px 1px 2px rgba(100, 100, 100, 0.5)' }} style={{ textShadow: '1px 1px 2px rgba(100, 100, 100, 0.5)' }}
onClick={() => onSelectFeed(null)}
> >
FlowReader FlowReader
</h1> </h1>
@@ -56,13 +51,23 @@ export function Sidebar({ onSelectFeed, selectedFeedId }: SidebarProps) {
<nav className="space-y-1"> <nav className="space-y-1">
<button <button
onClick={() => onSelectFeed(null)} onClick={() => markAllReadMutation.mutate()}
className={`w-full group flex items-center justify-between px-4 py-3 rounded-lg transition-all duration-300 ${selectedFeedId === null disabled={markAllReadMutation.isPending}
? 'bg-gold/20 text-yellow-700 shadow-sm border border-gold/20' className={`w-full group flex items-center justify-center space-x-3 px-4 py-3 rounded-lg transition-all duration-300 border ${markAllReadMutation.isPending
: 'text-paper-muted hover:text-gold hover:bg-gold/5' ? 'bg-gold/5 border-gold/10 text-gold/50 cursor-wait'
: 'bg-transparent border-gold/20 text-paper-muted hover:text-gold hover:bg-gold/5 hover:border-gold/40'
}`} }`}
title="Tout marquer comme lu"
> >
<span className="text-xs uppercase tracking-[0.2em] font-bold">Tout voir</span> <svg className={`w-4 h-4 ${markAllReadMutation.isPending ? 'animate-spin' : ''}`} fill="none" viewBox="0 0 24 24" stroke="currentColor">
{markAllReadMutation.isPending
? <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
: <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M5 13l4 4L19 7" />
}
</svg>
<span className="text-xs uppercase tracking-[0.2em] font-bold">
{markAllReadMutation.isPending ? 'Traitement...' : 'Tout marquer lu'}
</span>
</button> </button>
</nav> </nav>
</div> </div>