-
-
Notifications
You must be signed in to change notification settings - Fork 48
Recycle bin feature #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
8d85176
fef453e
71086f1
694eca5
05f6db3
deefa41
43eb6a5
a0b58e8
fa01852
8560449
965996e
f6db01c
c5271c0
043f0cb
bd4f796
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,8 +5,8 @@ | |||||
| import { FileText, ArrowLeft } from "lucide-react"; | ||||||
| import { toast } from "sonner"; | ||||||
|
|
||||||
| const Index = () => { | ||||||
| const { notes, createNote, updateNote, deleteNote } = useNotes(); | ||||||
| const Index = ({deletePage = false}: {deletePage?: boolean}) => { | ||||||
| const { notes, createNote, updateNote, deleteNote, softDeleteNote } = useNotes(); | ||||||
| const [activeNoteId, setActiveNoteId] = useState<string | null>(null); | ||||||
| const [isMobile, setIsMobile] = useState(false); | ||||||
|
|
||||||
|
|
@@ -17,6 +17,10 @@ | |||||
| return () => window.removeEventListener("resize", checkMobile); | ||||||
| }, []); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| setActiveNoteId(null); | ||||||
| }, [deletePage]) | ||||||
|
||||||
|
|
||||||
| const handleCreateNote = () => { | ||||||
| const newId = createNote(); | ||||||
| setActiveNoteId(newId); | ||||||
|
|
@@ -28,6 +32,12 @@ | |||||
| setActiveNoteId(notes.length > 1 ? notes[0].id : null); | ||||||
| } | ||||||
| }; | ||||||
| const handleSoftDeleteNote = (id: string) => { | ||||||
| softDeleteNote(id); | ||||||
| if (activeNoteId === id) { | ||||||
| setActiveNoteId(null); | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| const navigateNotes = (direction: "up" | "down") => { | ||||||
| if (notes.length === 0) return; | ||||||
|
|
@@ -104,7 +114,7 @@ | |||||
| return () => { | ||||||
| document.removeEventListener("keydown", handleKeyDown, true); | ||||||
| }; | ||||||
| }, [notes, activeNoteId]); | ||||||
|
Check warning on line 117 in src/pages/Index.tsx
|
||||||
|
|
||||||
| const activeNote = notes.find((note) => note.id === activeNoteId); | ||||||
|
|
||||||
|
|
@@ -118,7 +128,7 @@ | |||||
| activeNoteId={activeNoteId} | ||||||
| onSelectNote={setActiveNoteId} | ||||||
| onCreateNote={handleCreateNote} | ||||||
| onDelete={handleDeleteNote} // ADD THIS LINE | ||||||
| onDelete={ deletePage ? handleDeleteNote : handleSoftDeleteNote} | ||||||
|
||||||
| /> | ||||||
| <main className="flex-1 overflow-hidden relative"> | ||||||
| {/* Keyboard Shortcuts Helper */} | ||||||
|
|
@@ -162,7 +172,7 @@ | |||||
| <NoteEditor | ||||||
| note={activeNote} | ||||||
| onUpdate={updateNote} | ||||||
| onDelete={handleDeleteNote} | ||||||
| onDelete={ deletePage ? handleDeleteNote : handleSoftDeleteNote} | ||||||
|
||||||
| onDelete={ deletePage ? handleDeleteNote : handleSoftDeleteNote} | |
| onDelete={deletePage ? handleDeleteNote : handleSoftDeleteNote} |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after opening brace in conditional expression. Should be onDelete={deletePage ? handleDeleteNote : handleSoftDeleteNote}
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after opening brace in conditional expression. Should be onDelete={deletePage ? handleDeleteNote : handleSoftDeleteNote}
| onDelete={ deletePage ? handleDeleteNote : handleSoftDeleteNote} | |
| onDelete={deletePage ? handleDeleteNote : handleSoftDeleteNote} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolons at the end of these statements for consistency with the rest of the codebase.