mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-02 18:36:56 +01:00
refs #3300 Enable shortcut to move focus on statuses in DM
This commit is contained in:
parent
d0d1e9d5b4
commit
1a931edbd2
@ -11,8 +11,6 @@
|
||||
:filters="[]"
|
||||
v-on:update="updateToot"
|
||||
v-on:delete="deleteToot"
|
||||
@focusNext="focusNext"
|
||||
@focusPrev="focusPrev"
|
||||
@focusRight="focusSidebar"
|
||||
@selectToot="focusToot(item)"
|
||||
@sizeChanged="sizeChanged"
|
||||
@ -31,6 +29,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, computed, onMounted, onBeforeUpdate, onBeforeUnmount, onUnmounted, watch } from 'vue'
|
||||
import { useMagicKeys, whenever, and } from '@vueuse/core'
|
||||
import moment from 'moment'
|
||||
import { useStore } from '@/store'
|
||||
import { useI18next } from 'vue3-i18next'
|
||||
@ -56,6 +55,7 @@ export default defineComponent({
|
||||
const route = useRoute()
|
||||
const i18n = useI18next()
|
||||
const { reloadable } = useReloadable(store, route, i18n)
|
||||
const { j, k } = useMagicKeys()
|
||||
|
||||
const focusedId = ref<string | null>(null)
|
||||
const scrollPosition = ref<ScrollPosition | null>(null)
|
||||
@ -71,8 +71,9 @@ export default defineComponent({
|
||||
const openSideBar = computed(() => store.state.TimelineSpace.Contents.SideBar.openSideBar)
|
||||
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
|
||||
const unreadNotification = computed(() => store.state.TimelineSpace.timelineSetting.unreadNotification)
|
||||
const modalOpened = computed(() => store.getters[`TimelineSpace/Modals/modalOpened`])
|
||||
const modalOpened = computed<boolean>(() => store.getters[`TimelineSpace/Modals/modalOpened`])
|
||||
const currentFocusedIndex = computed(() => timeline.value.findIndex(toot => focusedId.value === toot.uri + toot.id))
|
||||
const shortcutEnabled = computed(() => !modalOpened.value)
|
||||
|
||||
onMounted(async () => {
|
||||
store.commit(`TimelineSpace/SideMenu/${SIDE_MENU_MUTATION.CHANGE_UNREAD_HOME_TIMELINE}`, false)
|
||||
@ -125,6 +126,23 @@ export default defineComponent({
|
||||
})
|
||||
}
|
||||
})
|
||||
watch(focusedId, (newVal, _oldVal) => {
|
||||
if (newVal && heading.value) {
|
||||
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, false)
|
||||
} else if (newVal === null && !heading.value) {
|
||||
store.commit(`${space}/${MUTATION_TYPES.CHANGE_HEADING}`, true)
|
||||
}
|
||||
})
|
||||
whenever(and(j, shortcutEnabled), () => {
|
||||
if (focusedId.value === null) {
|
||||
focusedId.value = timeline.value[0].id
|
||||
} else {
|
||||
focusNext()
|
||||
}
|
||||
})
|
||||
whenever(and(k, shortcutEnabled), () => {
|
||||
focusPrev()
|
||||
})
|
||||
|
||||
const initialize = async () => {
|
||||
await store.dispatch(`${space}/${ACTION_TYPES.FETCH_TIMELINE}`).catch(_ => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user