refs #750 Switch focus between Timelines and Account Profile using shortcut keys
This commit is contained in:
parent
8a5b4acaf6
commit
70638f6fab
|
@ -1,10 +1,35 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="account_timeline">
|
<div id="account_timeline">
|
||||||
<template v-for="message in pinnedToots">
|
<template v-for="message in pinnedToots">
|
||||||
<toot :message="message" :key="message.id" v-on:update="updateToot" v-on:delete="deleteToot" :pinned="true"></toot>
|
<toot
|
||||||
|
:message="message"
|
||||||
|
:key="message.id"
|
||||||
|
:focused="message.uri + message.id === focusedId"
|
||||||
|
:pinned="true"
|
||||||
|
:overlaid="modalOpened"
|
||||||
|
v-on:update="updateToot"
|
||||||
|
v-on:delete="deleteToot"
|
||||||
|
@focusNext="focusNext"
|
||||||
|
@focusPrev="focusPrev"
|
||||||
|
@focusLeft="focusTimeline"
|
||||||
|
@selectToot="focusToot(message)"
|
||||||
|
>
|
||||||
|
</toot>
|
||||||
</template>
|
</template>
|
||||||
<template v-for="message in timeline">
|
<template v-for="message in timeline">
|
||||||
<toot :message="message" :key="message.id" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
|
<toot
|
||||||
|
:message="message"
|
||||||
|
:key="message.id"
|
||||||
|
:focused="message.uri + message.id === focusedId"
|
||||||
|
:overlaid="modalOpened"
|
||||||
|
v-on:update="updateToot"
|
||||||
|
v-on:delete="deleteToot"
|
||||||
|
@focusNext="focusNext"
|
||||||
|
@focusPrev="focusPrev"
|
||||||
|
@focusLeft="focusTimeline"
|
||||||
|
@selectToot="focusToot(message)"
|
||||||
|
>
|
||||||
|
</toot>
|
||||||
</template>
|
</template>
|
||||||
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
<div class="loading-card" v-loading="lazyLoading" :element-loading-background="backgroundColor">
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,20 +37,31 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState, mapGetters } from 'vuex'
|
||||||
import Toot from '~/src/renderer/components/molecules/Toot'
|
import Toot from '~/src/renderer/components/molecules/Toot'
|
||||||
|
import { Event } from '~/src/renderer/components/event'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'timeline',
|
name: 'timeline',
|
||||||
props: [ 'account' ],
|
props: [ 'account' ],
|
||||||
components: { Toot },
|
components: { Toot },
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
focusedId: null
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState('TimelineSpace/Contents/SideBar/AccountProfile/Timeline', {
|
||||||
timeline: state => state.TimelineSpace.Contents.SideBar.AccountProfile.Timeline.timeline,
|
timeline: state => state.timeline,
|
||||||
pinnedToots: state => state.TimelineSpace.Contents.SideBar.AccountProfile.Timeline.pinnedToots,
|
pinnedToots: state => state.pinnedToots,
|
||||||
lazyLoading: state => state.TimelineSpace.Contents.SideBar.AccountProfile.Timeline.lazyLoading,
|
lazyLoading: state => state.lazyLoading
|
||||||
backgroundColor: state => state.App.theme.background_color
|
}),
|
||||||
})
|
...mapState('App', {
|
||||||
|
backgroundColor: state => state.theme.background_color
|
||||||
|
}),
|
||||||
|
...mapGetters('TimelineSpace/Modals', [
|
||||||
|
'modalOpened'
|
||||||
|
])
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.load()
|
this.load()
|
||||||
|
@ -33,6 +69,16 @@ export default {
|
||||||
mounted () {
|
mounted () {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/clearTimeline')
|
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/clearTimeline')
|
||||||
document.getElementById('sidebar_scrollable').addEventListener('scroll', this.onScroll)
|
document.getElementById('sidebar_scrollable').addEventListener('scroll', this.onScroll)
|
||||||
|
Event.$on('focus-sidebar', () => {
|
||||||
|
this.focusedId = 0
|
||||||
|
this.$nextTick(function () {
|
||||||
|
this.focusedId = this.timeline[0].uri + this.timeline[0].id
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
Event.$emit('focus-timeline')
|
||||||
|
Event.$off('focus-sidebar')
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
if (document.getElementById('sidebar_scrollable') !== undefined && document.getElementById('sidebar_scrollable') !== null) {
|
if (document.getElementById('sidebar_scrollable') !== undefined && document.getElementById('sidebar_scrollable') !== null) {
|
||||||
|
@ -77,6 +123,27 @@ export default {
|
||||||
},
|
},
|
||||||
deleteToot (message) {
|
deleteToot (message) {
|
||||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/deleteToot', message)
|
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/deleteToot', message)
|
||||||
|
},
|
||||||
|
focusNext () {
|
||||||
|
const currentIndex = this.timeline.findIndex(toot => this.focusedId === toot.uri + toot.id)
|
||||||
|
if (currentIndex === -1) {
|
||||||
|
this.focusedId = this.timeline[0].uri + this.timeline[0].id
|
||||||
|
} else if (currentIndex < this.timeline.length - 1) {
|
||||||
|
this.focusedId = this.timeline[currentIndex + 1].uri + this.timeline[currentIndex + 1].id
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focusPrev () {
|
||||||
|
const currentIndex = this.timeline.findIndex(toot => this.focusedId === toot.uri + toot.id)
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
this.focusedId = this.timeline[currentIndex - 1].uri + this.timeline[currentIndex - 1].id
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focusToot (message) {
|
||||||
|
this.focusedId = message.uri + message.id
|
||||||
|
},
|
||||||
|
focusTimeline () {
|
||||||
|
this.focusedId = 0
|
||||||
|
Event.$emit('focus-timeline')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,8 @@ export default {
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.load()
|
this.load()
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
Event.$on('focus-sidebar', () => {
|
Event.$on('focus-sidebar', () => {
|
||||||
this.focusedId = 0
|
this.focusedId = 0
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
|
@ -84,6 +86,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
|
Event.$emit('focus-timeline')
|
||||||
Event.$off('focus-sidebar')
|
Event.$off('focus-sidebar')
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in New Issue