fix: reload notes when moving to another lesson

This commit is contained in:
Jannat Patel
2025-08-06 11:13:16 +05:30
parent 77ecb02a17
commit 027dd93fb5
3 changed files with 13 additions and 15 deletions

View File

@@ -162,7 +162,6 @@ const deleteHighlight = () => {
const addToNotes = () => { const addToNotes = () => {
if (!selectedText.value) return if (!selectedText.value) return
console.log(selectedText.value)
let noteToUpdate = notes.value?.data.find((note: Note) => { let noteToUpdate = notes.value?.data.find((note: Note) => {
return !note.highlighted_text && note.note !== '' return !note.highlighted_text && note.note !== ''
}) })
@@ -171,7 +170,6 @@ const addToNotes = () => {
} else { } else {
updateNote(noteToUpdate) updateNote(noteToUpdate)
} }
console.log(noteToUpdate)
} }
const createNote = () => { const createNote = () => {

View File

@@ -42,11 +42,13 @@ const updateCurrentNote = () => {
const currentNote = notes.value?.data?.filter((row: Note) => { const currentNote = notes.value?.data?.filter((row: Note) => {
return !row.highlighted_text && row.note !== '' return !row.highlighted_text && row.note !== ''
}) })
if (!currentNote) return if (currentNote?.length === 0) {
if (currentNote.length > 0) { note.value = null
currentNoteName.value = null
return
}
currentNoteName.value = currentNote[0].name currentNoteName.value = currentNote[0].name
note.value = currentNote[0].note note.value = currentNote[0].note
}
} }
const updateNoteText = (val: string) => { const updateNoteText = (val: string) => {

View File

@@ -532,7 +532,7 @@ watch(
await nextTick() await nextTick()
resetLessonState(newChapterNumber, newLessonNumber) resetLessonState(newChapterNumber, newLessonNumber)
startTimer() startTimer()
notes.reload() updateNotes()
} }
} }
) )
@@ -784,14 +784,12 @@ const scrollDiscussionsIntoView = () => {
} }
const updateNotes = () => { const updateNotes = () => {
if (!notes.filters?.lesson) {
notes.update({ notes.update({
filters: { filters: {
lesson: lesson.data?.name, lesson: lesson.data?.name,
member: user.data?.name, member: user.data?.name,
}, },
}) })
}
notes.reload() notes.reload()
} }