perf: memo GridCard, fuse save fns, fix slash tab active color
This commit is contained in:
@@ -22,6 +22,10 @@ import {
|
||||
} from '@/lib/note-history'
|
||||
import { NOTE_LIST_SELECT } from '@/lib/note-select'
|
||||
|
||||
function stripNullBytes(str: string | null | undefined): string | null {
|
||||
if (str === null || str === undefined) return null
|
||||
return str.replace(/\u0000/g, '')
|
||||
}
|
||||
|
||||
async function ensureSessionUserExists(sessionUser: { id: string; email?: string | null; name?: string | null }) {
|
||||
const fallbackEmail = `user-${sessionUser.id}@local.momento`
|
||||
@@ -400,8 +404,8 @@ export async function createNote(data: {
|
||||
const note = await prisma.note.create({
|
||||
data: {
|
||||
userId: session.user.id,
|
||||
title: data.title || null,
|
||||
content: data.content,
|
||||
title: stripNullBytes(data.title) || null,
|
||||
content: stripNullBytes(data.content) || '',
|
||||
color: data.color || 'default',
|
||||
type: data.type || 'richtext',
|
||||
checkItems: data.checkItems ? JSON.stringify(data.checkItems) : null,
|
||||
@@ -563,6 +567,12 @@ export async function updateNote(id: string, data: {
|
||||
const oldNotebookId = oldNote?.notebookId
|
||||
|
||||
const updateData: any = { ...data }
|
||||
if (updateData.title !== undefined) {
|
||||
updateData.title = stripNullBytes(updateData.title)
|
||||
}
|
||||
if (updateData.content !== undefined) {
|
||||
updateData.content = stripNullBytes(updateData.content)
|
||||
}
|
||||
|
||||
// Reset isReminderDone only when reminder date actually changes (not on every save)
|
||||
if ('reminder' in data && data.reminder !== null) {
|
||||
@@ -984,6 +994,7 @@ export async function getAllNotes(includeArchived = false, notebookId?: string)
|
||||
|
||||
const sharedNotes = acceptedShares
|
||||
.map(share => share.note)
|
||||
.filter(Boolean)
|
||||
.filter(note => includeArchived || !note.isArchived)
|
||||
.map(note => ({ ...note, _isShared: true }))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user