From 007835c9bfc64c2fdb2ffc2555c6edfb17990091 Mon Sep 17 00:00:00 2001 From: sepehr Date: Sun, 26 Apr 2026 21:27:50 +0200 Subject: [PATCH] fix: capture session.user.id before .then() callback to satisfy TS null check TS doesn't narrow session.user inside async callback closures. Extract userId before the dynamic import to satisfy type checking. Co-Authored-By: Claude Opus 4.7 --- memento-note/components/note-inline-editor.tsx | 3 ++- memento-note/components/note-input.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/memento-note/components/note-inline-editor.tsx b/memento-note/components/note-inline-editor.tsx index c6495c7..b15d281 100644 --- a/memento-note/components/note-inline-editor.tsx +++ b/memento-note/components/note-inline-editor.tsx @@ -100,8 +100,9 @@ export function NoteInlineEditor({ useEffect(() => { if (session?.user?.id) { + const userId = session.user.id import('@/app/actions/ai-settings').then(({ getAISettings }) => { - getAISettings(session.user.id).then(settings => { + getAISettings(userId).then(settings => { setAiAssistantEnabled(settings.paragraphRefactor !== false) setAutoLabelingEnabled(settings.autoLabeling !== false) }).catch(err => console.error("Failed to fetch AI settings", err)) diff --git a/memento-note/components/note-input.tsx b/memento-note/components/note-input.tsx index 80c59bb..7f66727 100644 --- a/memento-note/components/note-input.tsx +++ b/memento-note/components/note-input.tsx @@ -88,8 +88,9 @@ export function NoteInput({ useEffect(() => { if (session?.user?.id) { + const userId = session.user.id import('@/app/actions/ai-settings').then(({ getAISettings }) => { - getAISettings(session.user.id).then(settings => { + getAISettings(userId).then(settings => { setAiAssistantEnabled(settings.paragraphRefactor !== false) setAutoLabelingEnabled(settings.autoLabeling !== false) }).catch(err => console.error("Failed to fetch AI settings", err))