mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-23 15:18:16 +02:00
feat: implement mobile note detail page for viewing, editing, and managing notes, todos, and images.
This commit is contained in:
1 parent
35ecd9a8bb
commit
96fe4857a0
1 file changed
+33
-2
@@ -39,6 +39,37 @@ export default function NoteDetailPage() {
|
|||||||
const [todoText, setTodoText] = useState("");
|
const [todoText, setTodoText] = useState("");
|
||||||
const [deleteModal, setDeleteModal] = useState(false);
|
const [deleteModal, setDeleteModal] = useState(false);
|
||||||
const [selectedImage, setSelectedImage] = useState<string | null>(null);
|
const [selectedImage, setSelectedImage] = useState<string | null>(null);
|
||||||
|
const [titleInput, setTitleInput] = useState("");
|
||||||
|
const [isTitleInitialized, setIsTitleInitialized] = useState(false);
|
||||||
|
|
||||||
|
// Initial sync of title when note loads
|
||||||
|
useEffect(() => {
|
||||||
|
if (note && !isTitleInitialized) {
|
||||||
|
setTitleInput(note.title);
|
||||||
|
setIsTitleInitialized(true);
|
||||||
|
} else if (note && note.id !== parseInt(id || "0")) {
|
||||||
|
// Handle navigation between notes where id changes
|
||||||
|
setTitleInput(note.title);
|
||||||
|
}
|
||||||
|
}, [note, id, isTitleInitialized]);
|
||||||
|
|
||||||
|
// Debounced title update
|
||||||
|
useEffect(() => {
|
||||||
|
if (!note || !isTitleInitialized) return;
|
||||||
|
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
if (titleInput !== note.title) {
|
||||||
|
updateNote({ title: titleInput });
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [titleInput, note, isTitleInitialized]);
|
||||||
|
|
||||||
|
// Reset initialization flag when id changes
|
||||||
|
useEffect(() => {
|
||||||
|
setIsTitleInitialized(false);
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadNote();
|
loadNote();
|
||||||
@@ -238,8 +269,8 @@ export default function NoteDetailPage() {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="Titre de la note"
|
placeholder="Titre de la note"
|
||||||
className="text-xl font-semibold border-none shadow-none px-0 focus-visible:ring-0"
|
className="text-xl font-semibold border-none shadow-none px-0 focus-visible:ring-0"
|
||||||
value={note.title || ""}
|
value={titleInput}
|
||||||
onChange={(e) => updateNote({ title: e.target.value })}
|
onChange={(e) => setTitleInput(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Action Buttons */}
|
{/* Action Buttons */}
|
||||||
|
|||||||
Reference in new issue
Block a user