fix keyboard and haptics
This commit is contained in:
@@ -8,6 +8,7 @@ import { defaultNotes } from '@/utils/defaultNotes'
|
||||
import { mdToHtml } from '@/utils/markdown'
|
||||
import { getAllMatches } from '@/utils/helpers'
|
||||
import { preferredNotesSource } from '@/composables/useSettings'
|
||||
import { Haptics, ImpactStyle } from '@capacitor/haptics'
|
||||
|
||||
export const notesSources = computed(() => ({
|
||||
local: true,
|
||||
@@ -89,7 +90,7 @@ export const notes = computed<Note[]>(() => {
|
||||
})
|
||||
watch(notes, () => {
|
||||
if (notes.value.length > 0 && !activeNote.value && activeViewMode.value.name === 'Note')
|
||||
setActiveNote(rootNote.value?.id)
|
||||
setActiveNote(rootNote.value?.id, false)
|
||||
})
|
||||
|
||||
const activeNoteId = ref<string>()
|
||||
@@ -99,10 +100,11 @@ watch(activeNote, () => {
|
||||
useTitle(`${activeNote.value.title} | Contexted`)
|
||||
}
|
||||
})
|
||||
export const setActiveNote = (noteId: string | undefined) => {
|
||||
export const setActiveNote = (noteId: string | undefined, haptic: boolean = true) => {
|
||||
if (noteId) {
|
||||
activeNoteId.value = noteId
|
||||
activeViewMode.value = viewModes.find((mode) => mode.name === 'Note') || viewModes[0]
|
||||
if (haptic) Haptics.impact({ style: ImpactStyle.Light })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +120,7 @@ export const setRootNote = (noteId: string) => {
|
||||
}
|
||||
const note = { ...baseNotes.value[noteId], isRoot: true }
|
||||
updateNote(noteId, note)
|
||||
setActiveNote(noteId)
|
||||
setActiveNote(noteId, false)
|
||||
}
|
||||
|
||||
export const insertDefaultNotes = (defaultNotes: BaseNote[]) => {
|
||||
@@ -268,5 +270,5 @@ export const getNotes = async () => {
|
||||
}
|
||||
baseNotes.value = parseBaseNotes(notes)
|
||||
if (!rootNote.value) insertDefaultNotes(defaultNotes)
|
||||
setActiveNote(rootNote.value?.id)
|
||||
setActiveNote(rootNote.value?.id, false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user