fix: update masonry grid sizing logic and notebook list padding

This commit is contained in:
Sepehr Ramezani
2026-02-14 14:20:32 +01:00
parent a0ffc9043b
commit 8f9031f076
580 changed files with 9789 additions and 42619 deletions

View File

@@ -458,7 +458,13 @@ export async function updateNote(id: string, data: {
// Explicitly handle size to ensure it propagates
if ('size' in data && data.size) updateData.size = data.size
updateData.updatedAt = new Date()
// Only update contentUpdatedAt for actual content changes, NOT for property changes
// (size, color, isPinned, isArchived are properties, not content)
const contentFields = ['title', 'content', 'checkItems', 'images', 'links']
const isContentChange = contentFields.some(field => field in data)
if (isContentChange) {
updateData.contentUpdatedAt = new Date()
}
const note = await prisma.note.update({
where: { id, userId: session.user.id },
@@ -471,16 +477,15 @@ export async function updateNote(id: string, data: {
await syncLabels(session.user.id, data.labels || [])
}
// IMPORTANT: Call revalidatePath to ensure UI updates
// BUT skip if only updating size (let optimistic UI handle it)
const isSizeOnlyUpdate = Object.keys(data).length === 1 && 'size' in data
// Only revalidate for STRUCTURAL changes that affect the page layout/lists
// Content edits (title, content, size, color) use optimistic UI — no refresh needed
const structuralFields = ['isPinned', 'isArchived', 'labels', 'notebookId']
const isStructuralChange = structuralFields.some(field => field in data)
if (!isSizeOnlyUpdate) {
// Revalidate main page, the note itself, and both old and new notebook paths
if (isStructuralChange) {
revalidatePath('/')
revalidatePath(`/note/${id}`)
// If notebook changed, revalidate both notebook paths
if (data.notebookId !== undefined && data.notebookId !== oldNotebookId) {
if (oldNotebookId) {
revalidatePath(`/notebook/${oldNotebookId}`)
@@ -776,7 +781,7 @@ export async function getAllNotes(includeArchived = false) {
}
// Get pinned notes only
export async function getPinnedNotes() {
export async function getPinnedNotes(notebookId?: string) {
const session = await auth();
if (!session?.user?.id) return [];
@@ -787,7 +792,8 @@ export async function getPinnedNotes() {
where: {
userId: userId,
isPinned: true,
isArchived: false
isArchived: false,
...(notebookId !== undefined ? { notebookId } : {})
},
orderBy: [
{ order: 'asc' },
@@ -817,10 +823,10 @@ export async function getRecentNotes(limit: number = 3) {
const notes = await prisma.note.findMany({
where: {
userId: userId,
updatedAt: { gte: sevenDaysAgo },
contentUpdatedAt: { gte: sevenDaysAgo },
isArchived: false
},
orderBy: { updatedAt: 'desc' },
orderBy: { contentUpdatedAt: 'desc' },
take: limit
})