build notes fix

This commit is contained in:
nmemmert
2026-06-18 13:46:41 -04:00
parent dd43d0c3ea
commit b77aba0167
2 changed files with 1 additions and 21 deletions
-20
View File
@@ -1491,7 +1491,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
const [noteMap, setNoteMap] = useState<Record<string, string>>({}) const [noteMap, setNoteMap] = useState<Record<string, string>>({})
const [openAnchor, setOpenAnchor] = useState<NoteAnchorId | null>(null) const [openAnchor, setOpenAnchor] = useState<NoteAnchorId | null>(null)
const [noteLoading, setNoteLoading] = useState(false) const [noteLoading, setNoteLoading] = useState(false)
const [noteSaving, setNoteSaving] = useState(false)
const [noteMessage, setNoteMessage] = useState('') const [noteMessage, setNoteMessage] = useState('')
const noteMapDirtyRef = useRef(false) const noteMapDirtyRef = useRef(false)
const [contextNoteMenu, setContextNoteMenu] = useState<{ x: number; y: number; text: string; anchor: NoteAnchorId } | null>(null) const [contextNoteMenu, setContextNoteMenu] = useState<{ x: number; y: number; text: string; anchor: NoteAnchorId } | null>(null)
@@ -1504,7 +1503,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
const [autoSaveMsg, setAutoSaveMsg] = useState('') const [autoSaveMsg, setAutoSaveMsg] = useState('')
const [_checkpointReflection, _setCheckpointReflection] = useState('') const [_checkpointReflection, _setCheckpointReflection] = useState('')
const canSaveNote = auth.authenticated && !noteSaving && !noteLoading
const savedNoteCount = Object.values(noteMap).filter(v => v?.trim()).length const savedNoteCount = Object.values(noteMap).filter(v => v?.trim()).length
const lessonAudioEmbedUrl = useMemo(() => { const lessonAudioEmbedUrl = useMemo(() => {
const trimmed = section?.audioEmbedUrl?.trim() ?? '' const trimmed = section?.audioEmbedUrl?.trim() ?? ''
@@ -1634,24 +1632,6 @@ export function ColossiansStudySectionPage({ content }: Props) {
setNoteMap(prev => ({ ...prev, [anchor]: html })) setNoteMap(prev => ({ ...prev, [anchor]: html }))
} }
async function saveNote() {
if (!noteId || !canSaveNote) return
setNoteSaving(true)
setNoteMessage('')
try {
await readJson<{ ok: boolean; note: string }>(`/api/study-notes/${encodeURIComponent(noteId)}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ note: JSON.stringify(noteMap) }),
})
noteMapDirtyRef.current = false
setNoteMessage('Notes saved.')
} catch (err) {
setNoteMessage(err instanceof Error ? err.message : 'Unable to save note.')
} finally {
setNoteSaving(false)
}
}
useEffect(() => { useEffect(() => {
if (!openAnchor) return if (!openAnchor) return
+1 -1
View File
@@ -23,7 +23,7 @@ export function NoteCard({ anchorLabel, html, autoSaveMsg, onChange, onClose }:
useEffect(() => { useEffect(() => {
if (!editor || editor.isDestroyed) return if (!editor || editor.isDestroyed) return
if (editor.getHTML() !== html) { if (editor.getHTML() !== html) {
editor.commands.setContent(html || '<p></p>', false) editor.commands.setContent(html || '<p></p>', { emitUpdate: false })
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [html]) }, [html])