Pages corrections journal

This commit is contained in:
alma 2026-01-16 12:41:28 +01:00
parent ab660b231e
commit 6c7719f764
2 changed files with 17 additions and 2 deletions

View File

@ -402,11 +402,15 @@ export default function CarnetPage() {
if (!skipCache) {
const cachedNotes = notesCache.get<Note[]>(cacheKey);
if (cachedNotes) {
console.log(`[fetchNotes] Using cached notes for ${folderLowercase} folder`);
console.log(`[fetchNotes] Using cached notes for ${folderLowercase} folder (${cachedNotes.length} notes)`);
setNotes(cachedNotes);
setIsLoadingNotes(false);
return;
} else {
console.log(`[fetchNotes] No cache found for ${folderLowercase} folder, fetching from API`);
}
} else {
console.log(`[fetchNotes] Skipping cache for ${folderLowercase} folder (skipCache=true)`);
}
// Fetch from API
@ -440,12 +444,14 @@ export default function CarnetPage() {
);
console.log(`[fetchNotes] Mapped ${uniqueNotes.length} unique notes from ${folderLowercase} folder (${mappedNotes.length} total before deduplication)`);
console.log(`[fetchNotes] Note titles:`, uniqueNotes.map(n => n.title));
// Update state
setNotes(uniqueNotes);
// Update cache
notesCache.set(cacheKey, uniqueNotes);
console.log(`[fetchNotes] Cache updated for ${folderLowercase} folder with ${uniqueNotes.length} notes`);
} else {
const errorData = await response.json().catch(() => ({}));
console.error('[fetchNotes] Error fetching notes:', errorData.message || response.statusText);

View File

@ -210,12 +210,21 @@ export function invalidateFolderCache(userId: string, folder: string): void {
const cacheKey = `${userId}-${folderLowercase}`;
// Clear notes list cache
const hadCache = notesCache.get(cacheKey) !== null;
notesCache.remove(cacheKey);
// Clear all note content caches for this folder (pattern match)
noteContentCache.clearPattern(`user-${userId}/${folderLowercase}/`);
console.log(`Cache invalidated for folder: ${folderLowercase}`);
console.log(`[invalidateFolderCache] Cache invalidated for folder: ${folderLowercase} (had cache: ${hadCache})`);
// Double-check that cache is cleared
const stillCached = notesCache.get(cacheKey);
if (stillCached) {
console.warn(`[invalidateFolderCache] WARNING: Cache still exists after removal for ${cacheKey}`);
// Force clear all matching keys
notesCache.clearPattern(cacheKey);
}
}
/**