From 068cce09b876cfabfafdf25898933c58f7aadff2 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Wed, 28 Nov 2018 22:57:30 +0900 Subject: [PATCH] refs #750 Switch focus between Public and Toot Detail using shortcut keys --- .../components/TimelineSpace/Contents/Public.vue | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/renderer/components/TimelineSpace/Contents/Public.vue b/src/renderer/components/TimelineSpace/Contents/Public.vue index 5ee6c1ff..a5b2cb81 100644 --- a/src/renderer/components/TimelineSpace/Contents/Public.vue +++ b/src/renderer/components/TimelineSpace/Contents/Public.vue @@ -14,6 +14,7 @@ v-on:delete="deleteToot" @focusNext="focusNext" @focusPrev="focusPrev" + @focusRight="focusSidebar" @selectToot="focusToot(message)" > @@ -33,6 +34,7 @@ import { mapState, mapGetters } from 'vuex' import Toot from '~/src/renderer/components/molecules/Toot' import scrollTop from '../../utils/scroll' import reloadable from '~/src/renderer/components/mixins/reloadable' +import { Event } from '~/src/renderer/components/event' export default { name: 'public', @@ -83,6 +85,15 @@ export default { }) } this.$store.commit('TimelineSpace/changeLoading', false) + + 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 + }) + }) }, beforeUpdate () { if (this.$store.state.TimelineSpace.SideMenu.unreadPublicTimeline && this.heading) { @@ -94,6 +105,7 @@ export default { this.$store.dispatch('TimelineSpace/stopPublicStreaming') this.$store.dispatch('TimelineSpace/unbindPublicStreaming') } + Event.$off('focus-timeline') }, destroyed () { this.$store.commit('TimelineSpace/Contents/Public/changeHeading', true) @@ -195,6 +207,9 @@ export default { focusToot (message) { this.focusedId = message.uri + message.id }, + focusSidebar () { + Event.$emit('focus-sidebar') + }, handleKey (event) { switch (event.srcKey) { case 'next':