pages
This commit is contained in:
parent
a31692f8b6
commit
8b8d2662b7
@ -23,8 +23,8 @@ interface EditorProps {
|
||||
}
|
||||
|
||||
export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'Notes', onRefresh }) => {
|
||||
const [title, setTitle] = useState(note?.title || '');
|
||||
const [content, setContent] = useState(note?.content || '');
|
||||
const [title, setTitle] = useState<string>(note?.title || '');
|
||||
const [content, setContent] = useState<string>(note?.content || '');
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@ -53,7 +53,7 @@ export const Editor: React.FC<EditorProps> = ({ 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<EditorProps> = ({ 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<EditorProps> = ({ 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<EditorProps> = ({ note, onSave, currentFolder = 'N
|
||||
};
|
||||
|
||||
if (note) {
|
||||
setTitle(note.title);
|
||||
setTitle(note.title || '');
|
||||
if (note.id) {
|
||||
fetchNoteContent();
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user