chore: snapshot before performance optimization
This commit is contained in:
@@ -114,7 +114,7 @@ export async function PUT(
|
||||
for (const note of allNotes) {
|
||||
if (note.labels) {
|
||||
try {
|
||||
const noteLabels: string[] = JSON.parse(note.labels)
|
||||
const noteLabels: string[] = Array.isArray(note.labels) ? (note.labels as string[]) : []
|
||||
const updatedLabels = noteLabels.map(l =>
|
||||
l.toLowerCase() === currentLabel.name.toLowerCase() ? newName : l
|
||||
)
|
||||
@@ -123,7 +123,7 @@ export async function PUT(
|
||||
await prisma.note.update({
|
||||
where: { id: note.id },
|
||||
data: {
|
||||
labels: JSON.stringify(updatedLabels)
|
||||
labels: updatedLabels as any
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -211,7 +211,7 @@ export async function DELETE(
|
||||
for (const note of allNotes) {
|
||||
if (note.labels) {
|
||||
try {
|
||||
const noteLabels: string[] = JSON.parse(note.labels)
|
||||
const noteLabels: string[] = Array.isArray(note.labels) ? (note.labels as string[]) : []
|
||||
const filteredLabels = noteLabels.filter(
|
||||
l => l.toLowerCase() !== label.name.toLowerCase()
|
||||
)
|
||||
@@ -220,7 +220,7 @@ export async function DELETE(
|
||||
await prisma.note.update({
|
||||
where: { id: note.id },
|
||||
data: {
|
||||
labels: filteredLabels.length > 0 ? JSON.stringify(filteredLabels) : null
|
||||
labels: (filteredLabels.length > 0 ? filteredLabels : null) as any
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user