fix: debouncing sync and other improvements
This commit is contained in:
@@ -1,29 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted } from 'vue'
|
||||
import type { LocalList } from '@/database/db'
|
||||
import { useEscapeKey } from '@/composables/useEscapeKey'
|
||||
|
||||
defineProps<{
|
||||
list: LocalList
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'close'): void
|
||||
(e: 'confirm'): void
|
||||
close: []
|
||||
confirm: []
|
||||
}>()
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('keydown', handleKeydown)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('keydown', handleKeydown)
|
||||
})
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.key === 'Escape') {
|
||||
handleClose()
|
||||
}
|
||||
}
|
||||
useEscapeKey(handleClose)
|
||||
|
||||
function handleClose() {
|
||||
emit('close')
|
||||
|
||||
Reference in New Issue
Block a user