This commit is contained in:
Stefan Hardegger
2025-08-18 10:41:32 +02:00
parent e952241e3c
commit 6b97c0a70f
3 changed files with 27 additions and 37 deletions

View File

@@ -93,27 +93,32 @@ export default function LibraryPage() {
// Enrich existing tags when fullTags are loaded // Enrich existing tags when fullTags are loaded
useEffect(() => { useEffect(() => {
if (fullTags.length > 0 && tags.length > 0) { if (fullTags.length > 0) {
// Check if tags already have color data to avoid infinite loops // Use functional update to get the current tags state
const hasColors = tags.some(tag => tag.color); setTags(currentTags => {
if (!hasColors) { if (currentTags.length > 0) {
// Re-enrich existing tags with color data // Check if tags already have color data to avoid infinite loops
const enrichedTags = tags.map(tag => { const hasColors = currentTags.some(tag => tag.color);
const fullTag = fullTags.find(ft => ft.name.toLowerCase() === tag.name.toLowerCase()); if (!hasColors) {
return { // Re-enrich existing tags with color data
...tag, return currentTags.map(tag => {
color: fullTag?.color, const fullTag = fullTags.find(ft => ft.name.toLowerCase() === tag.name.toLowerCase());
description: fullTag?.description, return {
aliasCount: fullTag?.aliasCount, ...tag,
createdAt: fullTag?.createdAt, color: fullTag?.color,
aliases: fullTag?.aliases, description: fullTag?.description,
id: fullTag?.id || tag.id aliasCount: fullTag?.aliasCount,
}; createdAt: fullTag?.createdAt,
}); aliases: fullTag?.aliases,
setTags(enrichedTags); id: fullTag?.id || tag.id
} };
});
}
}
return currentTags; // Return unchanged if no enrichment needed
});
} }
}, [fullTags, tags]); // Run when fullTags or tags change }, [fullTags]); // Only run when fullTags change
// Debounce search to avoid too many API calls // Debounce search to avoid too many API calls
useEffect(() => { useEffect(() => {

View File

@@ -29,7 +29,6 @@ export default function StoryCard({
const [updating, setUpdating] = useState(false); const [updating, setUpdating] = useState(false);
const handleRatingClick = async (e: React.MouseEvent, newRating: number) => { const handleRatingClick = async (e: React.MouseEvent, newRating: number) => {
console.log('Rating click:', newRating, 'for story:', story.title);
// Prevent default and stop propagation to avoid triggering navigation // Prevent default and stop propagation to avoid triggering navigation
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@@ -58,10 +57,7 @@ export default function StoryCard({
if (viewMode === 'list') { if (viewMode === 'list') {
return ( return (
<div <div className="theme-card theme-shadow rounded-lg p-4 hover:shadow-lg transition-shadow">
className="theme-card theme-shadow rounded-lg p-4 hover:shadow-lg transition-shadow"
onClick={(e) => console.log('Story card clicked (list view):', story.title, 'Target:', e.target)}
>
<div className="flex gap-4"> <div className="flex gap-4">
{/* Cover Image */} {/* Cover Image */}
<div className="flex-shrink-0"> <div className="flex-shrink-0">
@@ -176,10 +172,7 @@ export default function StoryCard({
// Grid view // Grid view
return ( return (
<div <div className="theme-card theme-shadow rounded-lg overflow-hidden hover:shadow-lg transition-shadow group">
className="theme-card theme-shadow rounded-lg overflow-hidden hover:shadow-lg transition-shadow group"
onClick={(e) => console.log('Story card clicked (grid view):', story.title, 'Target:', e.target)}
>
{/* Cover Image */} {/* Cover Image */}
<Link href={`/stories/${story.id}`}> <Link href={`/stories/${story.id}`}>
<div className="aspect-[3/4] bg-gray-200 dark:bg-gray-700 overflow-hidden"> <div className="aspect-[3/4] bg-gray-200 dark:bg-gray-700 overflow-hidden">

View File

@@ -21,15 +21,7 @@ export default function StoryMultiSelect({
const [selectedStoryIds, setSelectedStoryIds] = useState<string[]>([]); const [selectedStoryIds, setSelectedStoryIds] = useState<string[]>([]);
const [isSelectionMode, setIsSelectionMode] = useState(false); const [isSelectionMode, setIsSelectionMode] = useState(false);
console.log('StoryMultiSelect render:', {
storiesCount: stories.length,
isSelectionMode,
selectedCount: selectedStoryIds.length,
allowMultiSelect
});
const handleStorySelect = (storyId: string) => { const handleStorySelect = (storyId: string) => {
console.log('Story selection triggered:', storyId, 'Selection mode:', isSelectionMode);
setSelectedStoryIds(prev => { setSelectedStoryIds(prev => {
if (prev.includes(storyId)) { if (prev.includes(storyId)) {
const newSelection = prev.filter(id => id !== storyId); const newSelection = prev.filter(id => id !== storyId);