fix: prevent undefined history caused edit fail

undefined !== -1
This commit is contained in:
Nya Candy 2024-01-26 23:22:30 +08:00 committed by fly_mc
parent 7dc31a3ac1
commit 54b2449bf2

View file

@ -72,7 +72,7 @@ export class NoteUpdateService {
throw new Error('update time is required');
}
if (note.history?.findIndex(h => h.createdAt === ps.updatedAt?.toISOString()) !== -1) {
if (note.history && note.history.findIndex(h => h.createdAt === ps.updatedAt?.toISOString()) !== -1) {
// Same history already exists, skip this
return;
}