fix(note): address code review findings

- restoreVersion: ผ่าน validateAnnotationData ก่อน insert สาขา
  "ต้นทางถูกลบ" ให้สมมาตรกับสาขา update (invariant #8)
- PDFViewer: track timer ล้าง exportError ใน ref — กัน export พัง
  สองรอบติดกันแล้ว timer รอบแรกเคลียร์ error รอบหลังก่อนเวลา
- useHistory: เพิ่ม onError — undo/redo ล้มแสดง toast ผ่าน
  showActionError แทนหายเงียบ ๆ
- DebugConsole: ไม่โหลด Eruda จาก CDN ใน production build
  (ระบบ intranet + token อยู่ใน origin เดียวกัน)
- NoteHome: ตัด dead state session ที่ render ไม่ได้อ่าน
- note-auth: export SSO_REQUIRED_BANNER ให้หน้า gate ใช้ตรง ๆ
  ถอด non-null assertion ใน AnnotateView + bookmarkDepthOf

Verify: npx tsc --noEmit ผ่าน · vitest 317/317 ผ่าน

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Your Name 2026-11-02 10:01:00 +07:00
parent d37bc2a3f0
commit 2d466efd4f
7 changed files with 50 additions and 17 deletions

View file

@ -1011,6 +1011,9 @@ export async function restoreVersion(
if (v.userId !== uid) {
throw new Error("กู้คืนไม่ได้: เป็นรายการของผู้ใช้อื่น");
}
// validate สมมาตรกับสาขา "ต้นทางยังอยู่" — snapshot อาจเขียนสมัย validator หนาแน่น
// น้อยกว่าปัจจุบัน ห้ามไหลกลับเข้า annotations + SSE โดยไม่โดนตรวจ (invariant #8)
const validated = validateAnnotationData(v.type, v.data);
const [row] = await tx
.insert(annotations)
.values({
@ -1019,7 +1022,7 @@ export async function restoreVersion(
userId: v.userId,
userName: v.userName,
type: v.type,
data: v.data,
data: validated,
})
.returning();
return { action: "create" as const, row };