From 8b8d2662b7dba1c732dfab8c77ee578a47429b74 Mon Sep 17 00:00:00 2001 From: alma Date: Sun, 11 Jan 2026 23:15:15 +0100 Subject: [PATCH] pages --- components/carnet/editor.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/carnet/editor.tsx b/components/carnet/editor.tsx index e3df9e9..536610f 100644 --- a/components/carnet/editor.tsx +++ b/components/carnet/editor.tsx @@ -23,8 +23,8 @@ interface EditorProps { } export const Editor: React.FC = ({ note, onSave, currentFolder = 'Notes', onRefresh }) => { - const [title, setTitle] = useState(note?.title || ''); - const [content, setContent] = useState(note?.content || ''); + const [title, setTitle] = useState(note?.title || ''); + const [content, setContent] = useState(note?.content || ''); const [isSaving, setIsSaving] = useState(false); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); @@ -53,7 +53,7 @@ export const Editor: React.FC = ({ note, onSave, currentFolder = 'N const cachedContent = contentCache.current[note.id]; if (cachedContent && (Date.now() - cachedContent.timestamp) < CACHE_EXPIRATION) { console.log(`Using cached content for note ${note.title}`); - setContent(cachedContent.content); + setContent(cachedContent.content || ''); setIsLoading(false); return; } @@ -68,7 +68,7 @@ export const Editor: React.FC = ({ note, onSave, currentFolder = 'N if ((Date.now() - timestamp) < CACHE_EXPIRATION) { console.log(`Using localStorage cached content for note ${note.title}`); - setContent(content); + setContent(content || ''); // Update in-memory cache contentCache.current[note.id] = { content, timestamp }; @@ -94,7 +94,7 @@ export const Editor: React.FC = ({ note, onSave, currentFolder = 'N throw new Error(`Failed to fetch note content: ${response.status} ${errorText}`); } const data = await response.json(); - setContent(data.content); + setContent(data.content || ''); // Update both caches const newTimestamp = Date.now(); @@ -118,7 +118,7 @@ export const Editor: React.FC = ({ note, onSave, currentFolder = 'N }; if (note) { - setTitle(note.title); + setTitle(note.title || ''); if (note.id) { fetchNoteContent(); } else {