refs #750 Switch focus between Lists and Toot Detail using shortcut keys

This commit is contained in:
AkiraFukushima 2018-11-28 23:03:07 +09:00
parent 1edabdb50b
commit 8e1f376749
1 changed files with 15 additions and 0 deletions

View File

@ -14,6 +14,7 @@
v-on:delete="deleteToot" v-on:delete="deleteToot"
@focusNext="focusNext" @focusNext="focusNext"
@focusPrev="focusPrev" @focusPrev="focusPrev"
@focusRight="focusSidebar"
@selectToot="focusToot(message)" @selectToot="focusToot(message)"
> >
</toot> </toot>
@ -32,6 +33,7 @@ import { mapState, mapGetters } from 'vuex'
import Toot from '~/src/renderer/components/molecules/Toot' import Toot from '~/src/renderer/components/molecules/Toot'
import scrollTop from '../../../utils/scroll' import scrollTop from '../../../utils/scroll'
import reloadable from '~/src/renderer/components/mixins/reloadable' import reloadable from '~/src/renderer/components/mixins/reloadable'
import { Event } from '~/src/renderer/components/event'
export default { export default {
name: 'list', name: 'list',
@ -77,6 +79,16 @@ export default {
}) })
document.getElementById('scrollable').addEventListener('scroll', this.onScroll) document.getElementById('scrollable').addEventListener('scroll', this.onScroll)
}, },
mounted () {
Event.$on('focus-timeline', () => {
// If focusedId does not change, we have to refresh focusedId because Toot component watch change events.
const previousFocusedId = this.focusedId
this.focusedId = 0
this.$nextTick(function () {
this.focusedId = previousFocusedId
})
})
},
watch: { watch: {
list_id: function () { list_id: function () {
this.$store.commit('TimelineSpace/changeLoading', true) this.$store.commit('TimelineSpace/changeLoading', true)
@ -205,6 +217,9 @@ export default {
focusToot (message) { focusToot (message) {
this.focusedId = message.uri + message.id this.focusedId = message.uri + message.id
}, },
focusSidebar () {
Event.$emit('focus-sidebar')
},
handleKey (event) { handleKey (event) {
switch (event.srcKey) { switch (event.srcKey) {
case 'next': case 'next':