mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-03 02:37:55 +01:00
refs #3300 Enable shortcut to move focus on statuses in Favourites
This commit is contained in:
parent
1a931edbd2
commit
1d4a12acd7
@ -135,7 +135,7 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
whenever(and(j, shortcutEnabled), () => {
|
whenever(and(j, shortcutEnabled), () => {
|
||||||
if (focusedId.value === null) {
|
if (focusedId.value === null) {
|
||||||
focusedId.value = timeline.value[0].id
|
focusedId.value = timeline.value[0].uri + timeline.value[0].id
|
||||||
} else {
|
} else {
|
||||||
focusNext()
|
focusNext()
|
||||||
}
|
}
|
||||||
@ -255,8 +255,6 @@ export default defineComponent({
|
|||||||
modalOpened,
|
modalOpened,
|
||||||
updateToot,
|
updateToot,
|
||||||
deleteToot,
|
deleteToot,
|
||||||
focusNext,
|
|
||||||
focusPrev,
|
|
||||||
focusSidebar,
|
focusSidebar,
|
||||||
focusToot,
|
focusToot,
|
||||||
openSideBar,
|
openSideBar,
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
:filters="[]"
|
:filters="[]"
|
||||||
v-on:update="updateToot"
|
v-on:update="updateToot"
|
||||||
v-on:delete="deleteToot"
|
v-on:delete="deleteToot"
|
||||||
@focusNext="focusNext"
|
|
||||||
@focusPrev="focusPrev"
|
|
||||||
@focusRight="focusSidebar"
|
@focusRight="focusSidebar"
|
||||||
@selectToot="focusToot(item)"
|
@selectToot="focusToot(item)"
|
||||||
>
|
>
|
||||||
@ -30,6 +28,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, computed, ref, onMounted, onUnmounted, watch } from 'vue'
|
import { defineComponent, computed, ref, onMounted, onUnmounted, watch } from 'vue'
|
||||||
|
import { useMagicKeys, whenever, and } from '@vueuse/core'
|
||||||
import { useStore } from '@/store'
|
import { useStore } from '@/store'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { useI18next } from 'vue3-i18next'
|
import { useI18next } from 'vue3-i18next'
|
||||||
@ -52,14 +51,16 @@ export default defineComponent({
|
|||||||
const heading = ref<boolean>(false)
|
const heading = ref<boolean>(false)
|
||||||
const focusedId = ref<string | null>(null)
|
const focusedId = ref<string | null>(null)
|
||||||
const scroller = ref<any>()
|
const scroller = ref<any>()
|
||||||
|
const { j, k } = useMagicKeys()
|
||||||
|
|
||||||
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
|
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
|
||||||
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
|
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
|
||||||
const account = computed(() => store.state.TimelineSpace.account)
|
const account = computed(() => store.state.TimelineSpace.account)
|
||||||
const favourites = computed(() => store.state.TimelineSpace.Contents.Favourites.favourites)
|
const favourites = computed(() => store.state.TimelineSpace.Contents.Favourites.favourites)
|
||||||
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.Favourites.lazyLoading)
|
const lazyLoading = computed(() => store.state.TimelineSpace.Contents.Favourites.lazyLoading)
|
||||||
const modalOpened = computed(() => store.getters[`TimelineSpace/Modals/modalOpened`])
|
const modalOpened = computed<boolean>(() => store.getters[`TimelineSpace/Modals/modalOpened`])
|
||||||
const currentFocusedIndex = computed(() => favourites.value.findIndex(status => focusedId.value === status.uri))
|
const currentFocusedIndex = computed(() => favourites.value.findIndex(status => focusedId.value === status.uri))
|
||||||
|
const shortcutEnabled = computed(() => !modalOpened.value)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.getElementById('scroller')?.addEventListener('scroll', onScroll)
|
document.getElementById('scroller')?.addEventListener('scroll', onScroll)
|
||||||
@ -94,6 +95,17 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
whenever(and(j, shortcutEnabled), () => {
|
||||||
|
if (focusedId.value === null) {
|
||||||
|
focusedId.value = favourites.value[0].id
|
||||||
|
} else {
|
||||||
|
focusNext()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
whenever(and(k, shortcutEnabled), () => {
|
||||||
|
focusPrev()
|
||||||
|
})
|
||||||
|
|
||||||
const onScroll = (event: Event) => {
|
const onScroll = (event: Event) => {
|
||||||
if (
|
if (
|
||||||
(event.target as HTMLElement)!.clientHeight + (event.target as HTMLElement)!.scrollTop >=
|
(event.target as HTMLElement)!.clientHeight + (event.target as HTMLElement)!.scrollTop >=
|
||||||
@ -165,8 +177,6 @@ export default defineComponent({
|
|||||||
modalOpened,
|
modalOpened,
|
||||||
updateToot,
|
updateToot,
|
||||||
deleteToot,
|
deleteToot,
|
||||||
focusNext,
|
|
||||||
focusPrev,
|
|
||||||
focusSidebar,
|
focusSidebar,
|
||||||
focusToot,
|
focusToot,
|
||||||
openSideBar,
|
openSideBar,
|
||||||
|
@ -266,8 +266,6 @@ export default defineComponent({
|
|||||||
focusedId,
|
focusedId,
|
||||||
modalOpened,
|
modalOpened,
|
||||||
updateToot,
|
updateToot,
|
||||||
focusNext,
|
|
||||||
focusPrev,
|
|
||||||
focusSidebar,
|
focusSidebar,
|
||||||
focusNotification,
|
focusNotification,
|
||||||
sizeChanged,
|
sizeChanged,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user