From 1eef15f5024dfa0450f58847c7458ad8f0217b3d Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Mon, 12 Jan 2026 10:59:11 +0100 Subject: [PATCH] refactor(Notes): update favorite filtering logic for clarity and consistency in NotesPageClient and NotesList components --- src/app/notes/NotesPageClient.tsx | 11 +++++++---- src/components/notes/NotesList.tsx | 17 +++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/app/notes/NotesPageClient.tsx b/src/app/notes/NotesPageClient.tsx index 00dc89b..417c07d 100644 --- a/src/app/notes/NotesPageClient.tsx +++ b/src/app/notes/NotesPageClient.tsx @@ -284,11 +284,14 @@ function NotesPageContent({ // Filtrer les notes par dossier const filteredNotes = selectedFolderId === '__favorites__' - ? notes.filter((note) => note.isFavorite) // Notes favorites + ? notes.filter((note) => note.isFavorite === true) // Notes favorites : selectedFolderId === '__uncategorized__' ? notes.filter((note) => !note.folderId) // Notes sans dossier : selectedFolderId - ? notes.filter((note) => note.folderId === selectedFolderId) + ? notes.filter((note) => { + // Gérer les cas où folderId pourrait être undefined ou null + return note.folderId === selectedFolderId; + }) : notes; // Toutes les notes // Gérer le changement de dossier @@ -299,7 +302,7 @@ function NotesPageContent({ // Sélectionner automatiquement la première note du dossier const folderNotes = folderId === '__favorites__' - ? notes.filter((note) => note.isFavorite) + ? notes.filter((note) => note.isFavorite === true) : folderId === '__uncategorized__' ? notes.filter((note) => !note.folderId) : folderId @@ -422,7 +425,7 @@ function NotesPageContent({ availableTags={availableTags} onNoteDrop={handleNoteDrop} favoritesCount={ - notes.filter((note) => note.isFavorite).length + notes.filter((note) => note.isFavorite === true).length } /> diff --git a/src/components/notes/NotesList.tsx b/src/components/notes/NotesList.tsx index ffeb07b..dbde0dc 100644 --- a/src/components/notes/NotesList.tsx +++ b/src/components/notes/NotesList.tsx @@ -128,9 +128,14 @@ function SortableNoteItem({
-

- {getNoteTitle(note.content)} -

+
+ {note.isFavorite === true && ( + + )} +

+ {getNoteTitle(note.content)} +

+
{showDeleteConfirm === note.id ? (